Perl system() command failing under CYGWIN

Discussion in 'Perl Misc' started by Gordon, Sep 10, 2003.

  1. Gordon

    Gordon Guest

    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
    Gordon, Sep 10, 2003
    #1
    1. Advertising

  2. Gordon

    Helgi Briem Guest

    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.
    Helgi Briem, Sep 10, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Framcl

    system(); under Cygwin

    Framcl, Aug 8, 2003, in forum: C Programming
    Replies:
    7
    Views:
    444
    infecta
    Aug 14, 2003
  2. Michael
    Replies:
    3
    Views:
    432
    Christopher Benson-Manica
    Dec 7, 2005
  3. Pekka Niiranen
    Replies:
    7
    Views:
    298
    Joe Smith
    Jul 25, 2004
  4. Replies:
    2
    Views:
    977
  5. weston

    Known issues with Perl under Cygwin?

    weston, Aug 27, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    141
    Dave Weaver
    Sep 5, 2005
Loading...

Share This Page