Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Returning status to parent from pipe

by Crackers2 (Parson)
on Aug 25, 2010 at 20:53 UTC ( #857295=note: print w/replies, xml ) Need Help??


in reply to Returning status to parent from pipe

If you're using the bash shell something like this might work:

if (fork()){ } else { exec 'com1 | com2; exit $PIPESTATUS[0]'; }

You can read more about this in the bash manual.

Replies are listed 'Best First'.
Re^2: Returning status to parent from pipe
by morrin (Novice) on Aug 25, 2010 at 21:11 UTC
    Thanks for the replies I had read about the PIPESTATUS variable in bash ..... for some reason I thought that a perl exec would always run in 'sh'. It does on my system. Apologies if this is a very basic question, but can I change that so that it does run in a bash shell?
      On my system, /bin/sh runs bash. But you could specify which shell you want.
      exec(bash => (-c => 'com1 | com2; exit $PIPESTATUS[0]'));

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://857295]
help
Chatterbox?
[holli]: like dorothy?
[james28909]: see ya later holli
[james28909]: yeah like wizard of oz lol. its just a joke though
[james28909]: i cannot understand how someone cant see that a cloud of gas that evolves into a solar system or galaxies. it just makes sense to me. everythign that has happened, had to have happened for anything on this planet to be.
[james28909]: /gas/gas and debris/
[james28909]: another thing, i used to be atheist. life experiences, personal evidence. and my own perception is the reason why i believe the things i do.
[erix]: and now you are agnostic?
[james28909]: arunbear, your picking bits of history to fit your own narrative. right now, humans are smarter than in any of those times.
[james28909]: in order for there to be a mutation, there has to be a universe with laws setup that even allow a mutation.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2017-12-15 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (433 votes). Check out past polls.

    Notices?