#! /usr/bin/perl use strict; use Net::SSH::Expect; # Restarting the service.... my $ssh = Net::SSH::Expect->new ( host => "smailhostqa", user => 'root', raw_pty => 1 ); $ssh->run_ssh() or die "SSH process couldn't start: $!"; $ssh->send("/root/scripts/restart.sh"); print "foo"; $ssh->waitfor('[root\@\w+ ~]#'); $ssh->close();