Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: system command is not working

by gulla (Initiate)
on Dec 09, 2011 at 02:31 UTC ( #942547=note: print w/ replies, xml ) Need Help??


in reply to Re: system command is not working
in thread system command is not working

Thanks for the detailed analysis and step by step walk through.

I tried the way you have advised. However, this time my error file says that "/sbin/sh: system: not found". Below is the code I tried,

-------- #a.pl #!/usr/bin/perl system('ls -lrt > a.out'); -------- Comand $ at -f /tmp/a.pl now commands will be executed using /sbin/sh job 1323397408.a at Fri Dec 9 13:23:28 2011 Error: /sbin/sh: system: not found

I am wondering why the external system command is not recognized in the perl.

Any thoughts my friend. When the perl script is executed with "At" command, it invokes a shell to execute the script. However, that shell is unable to recoginse the system command. Is that correct??

Please let me know what else I can try to resolve this issue.

Thanks In Advance


Comment on Re^2: system command is not working
Download Code
Replies are listed 'Best First'.
Re^3: system command is not working
by choroba (Canon) on Dec 09, 2011 at 02:47 UTC
    I am wondering why the external system command is not recognized in the perl.
    The error is reported by /bin/sh, not perl. For some reason, the shell tries to interpret the script. Is the #!/usr/bin/perl line really the first one in your script?

      I do agree with you that the error is reported by /bin/sh not the perl. The perl script has just two lines; first line is

       #!/usr/bin/perl

      and second line is

       system('ls -lrt > c.out');

      Thanks, Anand

        The first two bytes of the file must be the characters #! You can not just have a few blank lines above your #!/usr/bin/perl line.

        This is a shell script (with line numbers showing), not a Perl script:

        1 2 #!/usr/bin/perl 3 4 echo This is really a shell script!

        If the first two bytes of the file are not #! then the system default shell will interpret the commands in the file. Thus, your error.

        Seriously, dude, you need to learn the basics of your Unix shell.

        dos2unix

        #!/usr/bin/perl  --

        #!/usr/bin/perl -w  --

        Seriously, read the FAQs linked

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-07-29 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls