in reply to Explicitly kill a Net::OpenSSH connection?

Hi, I never used it myself, but the docs for the module show you can get a $pid for the connection.
# various ways of starting a connection returning a $pid my ($in, $out ,$pid) = $ssh->open2("foo"); my ($pty, $pid) = $ssh->open2pty("foo"); my ($in, $out, $err, $pid) = $ssh->open3("foo"); my ($pty, $err, $pid) = $ssh->open3pty("login");
I would say you could either issue
kill 9, $pid;
#or in case some shells are hiding in there ( which may cause defunct process)
use Proc::Killfam; killfam 9, $pid

See Stopping subprocesses for a discussion of this. As a last resort, you can always search the process table for your process name, get the pid and kill it. Changing $0 of your script would make it easier to find in the process table, like

$0 = 'rastoboy-ssh'; # :-)

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Explicitly kill a Net::OpenSSH connection?
by rastoboy (Monk) on Aug 03, 2011 at 13:59 UTC
    Nice. Thank you Zentara :-)