josh803316 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Net::OpenSSH; my $username = 'username'; my $password = 'password'; my $params; my $session_obj; $session_obj = Net::OpenSSH->new("10.2.200.12", user => $username, pas +sword => $password, strict_mode => 0,master_opts => [ -o => "StrictHo +stKeyChecking=no"]); $session_obj->error and die "ssh failed: " . $session_obj->error; print Dumper($session_obj); # Each command runs in its own session my ($out,$err) = $session_obj->capture2('nohup /usr/sbin/tcpdump -i et +h1 -s 1500 -w /tmp/tmp.pcap &'); print "THE OUT IS $out\nTHE ERROR IS $err\n"; ($out,$err) = $session_obj->capture2('ping -I eth1 -c 3 192.168.107.25 +4'); print "THE OUT IS $out\nTHE ERROR IS $err\n"; ($out,$err) = $session_obj->capture2('killall tcpdump'); print "THE OUT IS $out\nTHE ERROR IS $err\n"; ($out,$err) = $session_obj->capture2('tcpdump -r /tmp/tmp.pcap'); print "THE OUT IS $out\nTHE ERROR IS $err\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::OpenSSH and background process
by josh803316 (Beadle) on Aug 24, 2010 at 15:31 UTC | |
by salva (Canon) on Aug 24, 2010 at 16:39 UTC | |
by josh803316 (Beadle) on Aug 24, 2010 at 23:28 UTC |