For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2007 > system return value?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author system return value?
g4173c@motorola.com

2007-01-26, 6:58 pm

Greetings:

I'm doing the following:

system ("make | tee /tmp/make.log") == 0 || die "Make failed $?\n";

The problem is that the pipe tee is what is getting returned for a
status. Is there anyway around this problem? The make fails but my
script doesn't exit out....

Thanks in advance!
Tom

Morten Guldager

2007-01-27, 3:57 am

2007-01-26 g4173c@motorola.com wrote
> Greetings:
>
> I'm doing the following:
>
> system ("make | tee /tmp/make.log") == 0 || die "Make failed $?\n";
>
> The problem is that the pipe tee is what is getting returned for a
> status. Is there anyway around this problem? The make fails but my
> script doesn't exit out....


How about launching your "make" in a open call?

open MAKE, "make|" or die "open: $!";
while (<MAKE> )
{
print STDERR $_;
}
my $exit_code_from_make = close MAKE;



/Morten %-)
Big and Blue

2007-02-02, 6:58 pm

g4173c@motorola.com wrote:
> Greetings:
>
> I'm doing the following:
>
> system ("make | tee /tmp/make.log") == 0 || die "Make failed $?\n";
>
> The problem is that the pipe tee is what is getting returned for a
> status. Is there anyway around this problem? The make fails but my
> script doesn't exit out....


How perverse do you wish to be:

system 'var=`((make; echo $?>&3) | tee /tmp/make.log) 3>&1`; exit $var ';


--
Just because I've written it doesn't mean that
either you or I have to believe it.
g4173c@motorola.com

2007-02-08, 6:58 pm

On Feb 2, 4:13 pm, Big and Blue <N...@dsl.pipex.com> wrote:

>
> system 'var=`((make; echo $?>&3) | tee /tmp/make.log) 3>&1`; exit $var ';
>


Interesting, but it no longer gets any output to the screen. Does get
the exit
status.

Tom

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com