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

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?

Replies are listed 'Best First'.
Re^4: system command is not working
by gulla (Initiate) on Dec 09, 2011 at 03:33 UTC

    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