dpraba3 has asked for the wisdom of the Perl Monks concerning the following question:

i'm trying to invoke a shell script to print last n lines in the file. if my shell script is:
tail --11 Test.txt
and the perl script contains :
system("tailsh.sh");
I get a error message :
tail.sh is not recognized as internal or external command, operable co +mmand or batch file.
Do I need to have a unix shell before I invoke shell script from perl?

Replies are listed 'Best First'.
Re: How to run a shell script from a Perl program?
by MidLifeXis (Monsignor) on Jul 18, 2008 at 16:44 UTC

    A few things:

    • Check your $PATH variable, or be explicit where you are calling your script from (eg: ./tailsh.sh.
    • Make certain that your tailsh.sh script has execute mode turned on (see chmod for details)
    • Make certain that you have a #!/path/to/program at the top of your tailsh.sh script, unless it can use the default shell without problems.

    --MidLifeXis