On 10 Sep 2003 01:19:21 -0700,
(Gordon) wrote:
>The following script run from the CYGWIN prompt (on the same PC),
>prints 'ls[return]' but fails to execute the 'system ("ls") command;
>no error is displayed it just skips over the system() line:
>!#g:/perl/bin
>print "ls\n";
>system("ls");
No, it works fine. Oh, you wanted to see the output?
Then you don't want to use the system function,
you want to use backticks or qx as specified in the
perlFAQ:
perlfaq -q "Why can't I get the output of a command with system()?"
If your cygwin directory is not in path, you may need
to supply the full path to ls. You will definitely have
to do that if this is supposed to run as a CGI.
You should also ALWAYS check external and
system calls for errors with warn or die as appropriate!
my $ls = 'C:/cygwin/bin/ls.exe';
my $output = qx/$ls/ or die "Cannot run $ls:$!\n";
print $output;
>Perl & Cygwin are supplied with the software, so I am hesitant to
>upgrade them. Perl is v5.005_002.
Ancient. Do yourself a favour and upgrade.
>I have tried the usual Google and mailing list archive searches with
>no luck. So, any suggestions are much appreciated.
perldoc comes first, Google later.