Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: "close" failing

by gellyfish (Monsignor)
on May 31, 2006 at 12:18 UTC ( [id://552765]=note: print w/replies, xml ) Need Help??


in reply to "close" failing

You probably do want to check the success of the close when you are doing a piped open like that. The likelihood is that the $ENV{PATH} is different for the web server process: you should either specify the full path to the program you are running or ensure that the location of the program is in $ENV{PATH} before opening the pipe. The reason you aren't seeing any error message is because the output of die is going to STDERR and mostly this goes into the error log rather than to the browser.

/J\

Replies are listed 'Best First'.
Re^2: "close" failing
by jdhedden (Deacon) on May 31, 2006 at 12:37 UTC
    I don't think that $ENV{PATH} has anything to do with the failure of the close statement. It would affect the success of open, but not close. Or am I missing something?

    Remember: There's always one more bug.

      The return value of a piped open tells you if the fork succeeded or not, the return value of close tells you about the execution status of the program in the pipe. So, if $ENV{PATH} is set such that perl can't find the program to be piped to/from, close will return a false value (perl was able to successfully fork, but not execute the piped command).

        I tried this, and it doesn't work as you described: If Perl can't find the program to be piped to, the open command fails.

        Remember: There's always one more bug.

        I'm not entirely sure that's correct. For my test code, if the program cannot be found, open will not succeed.

        #!/usr/bin/perl -w use strict; open(BAD, "/no-such-path/not_here.sh |") || die "Died with: $!\n"; close(BAD);
        Does in fact die on open with Died with: No such file or directory.

        -- vek --
      thanks a lot for the replies. You are right here. Because the print statements worked fine after the open call. (in "do processing" section). So, it cannot be that open has failed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found