Net::SSH::Perl running under mod_perl2
Earlier I posted a problem noting that i couldn't getNet::SSH::Perl to work in mod_perl2. It turns out that it is possible. Basically there is a problem with STDIN and STDOUT in mod_perl when using sub-processes that expect these to be normal. (explained better than I can here: http://perl.apache.org/docs/2.0/api/Apache2/SubProcess.html)
The solution is to redirect STDIN and STDOUT to /dev/null for the command. Adapting the code on the above page (because it uses features unavailable in mod_perl2 and unnecessary in current version of perl) simply replace:
my ($out, $err, $exit) = $ssh->cmd($cmd);
with
my ($out, $err, $exit); warn "executing: $cmd"; { my $nullfh; open $nullfh, '>/dev/null' or die "Can't open /dev/null: $!"; local *STDOUT = $nullfh; ($out, $err, $exit) = $ssh->cmd($cmd); close $nullfh; }











