in reply to Re: Net::OpenSSH and background process
in thread Net::OpenSSH and background process

nohup only does its redirection magic when stdin/stdout/stderr are connected to a tty, that's why you need to explicitly redirect these streams.

Besides that, you can use Net::OpenSSH spawn method to launch the command in the background:

# this code does not check for errors! my $pid = $ssh->spawn('/usr/sbin/tcpdump -i eth1 -s 1500 -w /tmp/tmp.p +cap'); ($out,$err) = $ssh->capture2('ping -I eth1 -c 3 192.168.107.254'); $ssh->system('killall tcpdump'); waitpid($pid, 0); ($out,$err) = $ssh->capture2('tcpdump -r /tmp/tmp.pcap'); print "THE OUT IS $out\nTHE ERROR IS $err\n";

Replies are listed 'Best First'.
Re^3: Net::OpenSSH and background process
by josh803316 (Beadle) on Aug 24, 2010 at 23:28 UTC
    Thank you for the info and helpful example. I was able to get it working both ways with both spawn and the nohup as you suggested. I sincerely appreciate the help!!!