in reply to Re^2: Net::SFTP::Foreign Connection STDERR
in thread Net::SFTP::Foreign Connection STDERR

File::Temp sets the close-on-exec flag, so for ssh to be able to actually write to the file, you need to clear it:
use Fcntl qw(F_SETFD F_GETFD FD_CLOEXEC); my $ssherr = File::Temp->new; my $flags = fcntl($ssherr, F_GETFD, 0) or die "Can't get FD flags for '$ssherr': $!"; fcntl($ssh_err, F_SETFD, $flags & ~FD_CLOEXEC) or die "Cant clear close-on-exec flag for '$ssherr': $!"; <the rest of your code>

Replies are listed 'Best First'.
Re^4: Net::SFTP::Foreign Connection STDERR
by salva (Canon) on Apr 21, 2009 at 14:46 UTC
    This may be operative system dependent.

    In Linux, it seems that the dup2 system call behind the "open ... >&..." does not copy the close-on-exit flag, and so your proposed change is not required.

    Which perl version and operative system are you using?