Perl system() command failing under CYGWIN

G

Gordon

Hi,
I am trying to install a software product that uses Perl under CYGWIN
and am having a problem with the Perl system() command failing.

The following script works from a Windows 2000 cmd prompt:
!#g:\perl\bin
print "dir\n";
system ( "dir");

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");

Perl & Cygwin are supplied with the software, so I am hesitant to
upgrade them. Perl is v5.005_002. PC is running Windows 2000 Server
SP3 as recommended by the software supplier.

I have tried the usual Google and mailing list archive searches with
no luck. So, any suggestions are much appreciated.

TIA,
Gordon
 
H

Helgi Briem

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top