J
jrpfinch
This post if a followup to
http://groups.google.co.uk/group/pe...?lnk=gst&q=piping+out&rnum=1#1ed10e63c905a3e7.
It is a distinct topic, however, so I've started a new thread.
In the previous post, I managed to create a script that permanently
logged the output from a C executable that was always open. It used
the Expect module.
I would now like to do the same thing but remotely over SSH. For
security reasons, I am not allowed to go for the easy option of
exchanging unpassworded keys and using batch mode.
The script at the base of this email simply returns the following
output, without returning the output from 'ls':
bash-2.05# perl expectssh.pl
Password: bash-2.05#
use strict;
use warnings;
use Expect;
my $password = "password";
my $conn = Expect->spawn("ssh root\@10.247.16.2 ls") or die "Couldn't
spawn ssh\n";
if ($conn->expect(20,"Password: "))
{
print $conn "$password\n";
}
else
{
die "Never got username prompt on bla, ".$conn->exp_error()."\n";
}
http://groups.google.co.uk/group/pe...?lnk=gst&q=piping+out&rnum=1#1ed10e63c905a3e7.
It is a distinct topic, however, so I've started a new thread.
In the previous post, I managed to create a script that permanently
logged the output from a C executable that was always open. It used
the Expect module.
I would now like to do the same thing but remotely over SSH. For
security reasons, I am not allowed to go for the easy option of
exchanging unpassworded keys and using batch mode.
The script at the base of this email simply returns the following
output, without returning the output from 'ls':
bash-2.05# perl expectssh.pl
Password: bash-2.05#
use strict;
use warnings;
use Expect;
my $password = "password";
my $conn = Expect->spawn("ssh root\@10.247.16.2 ls") or die "Couldn't
spawn ssh\n";
if ($conn->expect(20,"Password: "))
{
print $conn "$password\n";
}
else
{
die "Never got username prompt on bla, ".$conn->exp_error()."\n";
}