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. So I tried to create a pipe by my own using "pipe". After that I call "fork". Then the mail is passed to ssh via the created pipe. But this doesn't work. Here is my current version of the script. For debugging reasons I call "cat" instead of "ssh". But I get no output. ---8<--------------------------------------------------------------------- #!/usr/bin/perl my $lb = $/; $/ = undef; my $mail = <STDIN>; $/ = $lb; my $pid; pipe(READ, WRITE); $pid = fork(); if ($pid == 0) { close(WRITE); exec('cat'); exit(1); } elsif ($pid > 0) { close(READ); my $old_handle = select(WRITE); $| = 1; print WRITE $mail; waitpid($pid, WNOHANG); $retval = $? >> 8; select($old_handle); print "$retval\n"; } ---8<--------------------------------------------------------------------- Thanks, Andreas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/