Reputation: 291
i am tasked with Perl to ssh into another server and stop/start/restart the process if it is not already started.
i will break this down into small chunks:
::how can i ssh into a server, and read a pid file and bring back the #?::
i can do this: system("ssh serverid.gcsc.att.com -l myid -i /home/myid/.ssh/authorized_keys 'kill -9 1234'"); just fine, kill the process after authenticating into the server.
but how do i read a pid file/any file on that server, and get the value into a variable so that i can then ssh and kill the process?
Upvotes: 0
Views: 238
Reputation: 53478
Easiest way is with backticks.
my $output = `ssh server -l myid -i /home/myid/.ssh/authorized_keys some_command`;
$output
will contain the output of your ssh
command.
Upvotes: 2