From: Andreas Brillisauer - Hetzner Online AG <[EMAIL
PROTECTED]>
> Hello,
>
> I'm just writing a script that gets an email from stdin. This mail
> should be passed to procmail via ssh. If calling ssh or procmail
> fails, the mail should be saved locally.
>
> First I tried to solve this with "system" or "open". But I cannot pipe
> the mail to ssh when using "system". "open" can handle a pipe to ssh
> but doesn't return the return value of ssh.
Maybe because by the time oepn() returns it only knows whether it was
able to start the process. And since the process does and needs to
run for some more time open() can't return the return value. but
close() can:
perldoc -f close
close FILEHANDLE
close Closes the file or pipe associated with the file handle,
returning true only if IO buffers are successfully flushed and
closes the system file descriptor. Closes the currently selected
filehandle if the argument is omitted.
You don't have to close FILEHANDLE if you are immediately going
to do another "open" on it, because "open" will close it for
you. (See "open".) However, an explicit "close" on an input file
resets the line counter ($.), while the implicit close done by
"open" does not.
If the file handle came from a piped open, "close" will
additionally return false if one of the other system calls
involved fails, or if the program exits with non-zero status.
(If the only problem was that the program exited non-zero, $!
will be set to 0.) Closing a pipe also waits for the process
executing on the pipe to complete, in case you want to look at
the output of the pipe afterwards, and implicitly puts the exit
status value of that command into $?.
HTH, Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/