use IPC::PerlSSH; eval { my $ips = IPC::PerlSSH->new( Host => "somehost" ); print $ips->eval("1")."\n"; <>; # allow me to cut ssh connection print $ips->eval("2")."\n"; }; if ($@) { print "error: $@"; } print "done\n"; #### $ perl test_ipc_perlssh.pl 1 [pressed enter] 2 done $ #### $ perl test_ipc_perlssh.pl 1 [killed sshd on remote] Connection to somehost closed by remote host. [pressed enter] $