Spawning external programs and running system commands from Windows

Discussion in 'Perl Misc' started by Sol Linderstein, Jun 1, 2004.

  1. Hi,

    I'm trying to do something trivial with ActivePerl on an XP machine
    with no success.

    C:\PERL\TEST>perl
    system("dir");
    ^D

    I get no output. In Unix this command works fine, substituting 'ls'
    for 'dir'. My perl install is working because other programs, that
    don't spawn external programs produce the expected output to the
    screen.

    I'm basically trying to call an external program from perl in a
    Windows environment and the system/dir example is the easiest one I
    can think of and it doesn't produce any output. I've tried various
    other things, namely backticking and piping which work in Unix.

    What's the trick to spawning external programs from Perl in Windows?

    Thanks,
    SL
     
    Sol Linderstein, Jun 1, 2004
    #1
    1. Advertising

  2. Sol Linderstein

    gnari Guest

    "Sol Linderstein" <> wrote in message
    news:...
    > Hi,
    >
    > I'm trying to do something trivial with ActivePerl on an XP machine
    > with no success.
    >
    > C:\PERL\TEST>perl
    > system("dir");
    > ^D


    should work.

    as should:

    C:\PERL\TEST>perl
    print qx(dir);
    ^D

    gnari
     
    gnari, Jun 1, 2004
    #2
    1. Advertising

  3. (Sol Linderstein) wrote in
    news::

    > Hi,
    >
    > I'm trying to do something trivial with ActivePerl on an XP machine
    > with no success.
    >
    > C:\PERL\TEST>perl
    > system("dir");
    > ^D


    dir is a built-in command. The EOF character on for cmd and command
    shells is ^Z (although ^D also seems to work on my machine with perl in
    this case).

    What you need is:

    C:\Home\asu1> perl
    system 'cmd /c dir *.txt';
    ^Z
    Volume in drive C is HD
    Volume Serial Number is F882-4E55

    Directory of C:\Home\asu1

    2004/05/12 09:12 PM 1,211 a.txt
    2004/03/12 05:36 AM 4,278 ahsn.txt
    2004/03/11 03:41 PM 103 asu1.sig.txt
    2004/05/12 09:12 PM 1,131 b.txt
    2003/08/20 02:04 PM 15,324 basicauth.txt

    ....

    > I'm basically trying to call an external program from perl in a
    > Windows environment and the system/dir example is the easiest one I
    > can think of and it doesn't produce any output. I've tried various
    > other things, namely backticking and piping which work in Unix.
    >
    > What's the trick to spawning external programs from Perl in Windows?


    There is no real trick but just to be sure, you might want to post a
    short example showing your problem.

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, Jun 1, 2004
    #3
    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. caleb
    Replies:
    0
    Views:
    2,889
    caleb
    Jan 3, 2006
  2. Replies:
    12
    Views:
    1,661
    Dave Thompson
    Jan 10, 2005
  3. Nico Kruger
    Replies:
    0
    Views:
    388
    Nico Kruger
    Apr 12, 2006
  4. Tommy  B
    Replies:
    4
    Views:
    285
    Tommy B
    May 30, 2006
  5. lone_eagle
    Replies:
    3
    Views:
    644
    psykeedelik
    May 26, 2009
Loading...

Share This Page