Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > perl system command

Reply
Thread Tools

perl system command

 
 
keepyourstupidspam@yahoo.co.uk
Guest
Posts: n/a
 
      04-05-2007
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

 
Reply With Quote
 
 
 
 
Mumia W.
Guest
Posts: n/a
 
      04-05-2007
On 04/05/2007 04:30 PM, http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-06-2007
(E-Mail Removed) <(E-Mail Removed)> 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
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      04-06-2007
(E-Mail 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.

--
Affijn, Ruud

"Gewoon is een tijger."

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      04-06-2007
Tad McClellan <(E-Mail Removed)> wrote:
> (E-Mail Removed) <(E-Mail Removed)> 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
 
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
suppress opening command window after using os.system command boriq Python 4 06-12-2008 10:42 AM
Pull out only first field of ps command ( in Perl ) PERL RUN COMMAND tweetiebirds@gmail.com Perl Misc 2 03-26-2005 06:03 AM
A question about Perl: using perl command line to replace strings... lucy Perl Misc 7 09-03-2004 07:57 AM
Overloaded "echo" command in perl within system (backtick, exec) call Leszek Dubiel Perl 3 05-12-2004 11:43 AM
Re: Cplex hangs in Perl system command Paul A. Rubin Perl 2 08-05-2003 10:15 PM



Advertisments