Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: "close" failing

by jesuashok (Curate)
on May 31, 2006 at 12:40 UTC ( #552769=note: print w/ replies, xml ) Need Help??


in reply to "close" failing

Hi

The problem is because of Pipe. There is no wait specified to finish "abc.sh".

open(OUTPUT, '|sort >foo') # pipe to sort or die "Can't start sort: $!"; #... # print stuff to output close OUTPUT # wait for sort to finish or warn $! ? "Error closing sort pipe: $!" : "Exit status $? from sort";
Please refere the above code and comment. If you use warn you will get the error in server logs as well.

"Keep pouring your ideas"


Comment on Re: "close" failing
Download Code
Replies are listed 'Best First'.
Re^2: "close" failing
by derby (Abbot) on May 31, 2006 at 12:52 UTC

    That's not really a wait issue. When closing a piped open filehandle, if the opened command exits with a non-zero and that's the only issue with the command, then $! is set to 0. So the code above is using the tertiary operater to check that condition. I thought that might be the issue too but the OP said it worked fine from the command line so more than likely there's either a path or permisssion issue.

    -derby
Re^2: "close" failing
by liverpole (Monsignor) on Oct 16, 2006 at 12:39 UTC
    The code jesuashok posted was simply copied verbatim from the example section of perldoc entry for close, even to the point of including the comment containing the ellipses "#...":
    open(OUTPUT, '|sort >foo') # pipe to sort or die "Can't start sort: $!"; #... # print stuff to output close OUTPUT # wait for sort to finish or warn $! ? "Error closing sort pipe: $!" : "Exit status $? from sort"; open(INPUT, 'foo') # get sort's results or die "Can't open 'foo' for input: $!";

    Refer to this node for further discussion of jesuashok's posting habits.


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://552769]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2015-07-30 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls