How to open a remote shell using perl
I want to open a remote ssh session using the perl script , I am able to login
to the server using the simple script and i am also able to execute few
commands on the server.
I am writing a script which takes the user name , password and hostname from the
database and login to the server .
I need to run command once I have logged in using my script and I want to track
down all the commands being executed in a particular session.
I know how to run command on remote shell using script , but I want to open
remote shell using perl and want to run the command manually and terminate the
session when I am done as we normally do with bash shell .
Here is my code which logs in and performs some task but it does not show the
output of top and pstree command what would i do to get the output of these
commands along with "vmstat 1 10" and "iostat 1" , "top -cd2" etc..
$host = '192.168.3.36';
$username = 'root';
$login_passwd = 'password';
my $ssh = Net::SSH::Perl->new($host);
$cmd = $_;
my($stdout,$sterr, $stderr) = $ssh->cmd("$cmd");
print "\n$stdout\n$stderr ";
print "logging out from the server " if eof;
[Non-text portions of this message have been removed]