perl system command

G

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
 
M

Mumia W.

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.
 
T

Tad McClellan

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().
 
D

Dr.Ruud

(e-mail address removed) 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.
 
X

xhoster

Tad McClellan said:
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
 

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