Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl system() command failing under CYGWIN

Reply
Thread Tools

Perl system() command failing under CYGWIN

 
 
Gordon
Guest
Posts: n/a
 
      09-10-2003
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
 
Reply With Quote
 
 
 
 
Helgi Briem
Guest
Posts: n/a
 
      09-10-2003
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cygwin make does not execute command under XP Michael C Programming 3 12-07-2005 02:02 PM
Known issues with Perl under Cygwin? weston Perl Misc 3 09-05-2005 07:03 AM
How to set the baud rate on a serial port (Perl under cygwin)? arkadyz1@yahoo.com Perl Misc 2 01-06-2005 06:58 PM
confirm unsubscribe from cygwin-announce@cygwin.com cygwin-announce-help@cygwin.com Python 0 09-05-2003 01:29 AM
confirm unsubscribe from cygwin@cygwin.com cygwin-help@cygwin.com Python 0 09-04-2003 06:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57