perl system command

Discussion in 'Perl Misc' started by keepyourstupidspam@yahoo.co.uk, Apr 5, 2007.

  1. Guest

    Hi,

    I am trying to run this command using system but it fails.

    gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
    \scripts\tee.pl build.log


    @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
    "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
    "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");

    system(@args1) == 0
    or die "system @args failed: $?";

    Anyone know how to get this to work?


    Enda
    , Apr 5, 2007
    #1
    1. Advertising

  2. Mumia W. Guest

    On 04/05/2007 04:30 PM, wrote:
    > Hi,
    >
    > I am trying to run this command using system but it fails.
    >
    > gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
    > \scripts\tee.pl build.log
    >
    >
    > @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
    > "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
    > "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
    >
    > system(@args1) == 0
    > or die "system @args failed: $?";
    >
    > Anyone know how to get this to work?
    >
    >
    > Enda
    >


    AFAIK, this form of the system command omits starting the shell, so
    shell redirection attempts ("2>&1" and "| perl") should fail. You would
    have to put everything into a single string.
    Mumia W., Apr 5, 2007
    #2
    1. Advertising

  3. <> wrote:
    > Hi,
    >
    > I am trying to run this command using system but it fails.
    >
    > gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
    > \scripts\tee.pl build.log
    >
    >
    > @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
    > "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
    > "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
    >
    > system(@args1) == 0
    > or die "system @args failed: $?";



    The "system PROGRAM LIST" (more that one argument) form of system()
    does not invoke a shell, so you cannot expect shell constructs,
    such as file redirection, to work.


    > Anyone know how to get this to work?



    Pass a single argument to system().


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Apr 6, 2007
    #3
  4. Dr.Ruud Guest

    schreef:

    > I am trying to run this command using system but it fails.
    >
    > gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
    > \scripts\tee.pl build.log
    >
    >
    > @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
    > "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
    > "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
    >
    > system(@args1) == 0
    > or die "system @args failed: $?";
    >
    > Anyone know how to get this to work?


    Rewrite tee.pl to use open on the gmake, and deal with STDIN and STDERR
    itself.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Apr 6, 2007
    #4
  5. Guest

    Tad McClellan <> wrote:
    > <> wrote:
    > > Hi,
    > >
    > > I am trying to run this command using system but it fails.
    > >
    > > gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
    > > \scripts\tee.pl build.log
    > >
    > >
    > > @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
    > > "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
    > > "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
    > >
    > > system(@args1) == 0
    > > or die "system @args failed: $?";

    >
    > The "system PROGRAM LIST" (more that one argument) form of system()
    > does not invoke a shell, so you cannot expect shell constructs,
    > such as file redirection, to work.


    Just a minor nit to pick. The "system PROGRAM LIST" form does not have a
    comma between PROGRAM and LIST; it uses a syntax like print with a
    filehandle does. And it does something different (lies about the program
    name.)

    The behavior you describe results from LIST having more than one element
    (or being an array with more than one member), not from PROGRAM being
    present.

    I believe that the presence of PROGRAM and the difference in shell behavior
    depending on the length of LIST are orthogonal features.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Apr 6, 2007
    #5
    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. Paul A. Rubin

    Re: Cplex hangs in Perl system command

    Paul A. Rubin, Aug 4, 2003, in forum: Perl
    Replies:
    2
    Views:
    3,611
    Paul A. Rubin
    Aug 5, 2003
  2. Leszek Dubiel
    Replies:
    3
    Views:
    9,810
  3. Irmen de Jong
    Replies:
    2
    Views:
    428
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=
    Aug 12, 2003
  4. boriq
    Replies:
    4
    Views:
    583
    Tim Golden
    Jun 12, 2008
  5. Replies:
    2
    Views:
    159
    Tad McClellan
    Mar 26, 2005
Loading...

Share This Page