Perl feed handler on Linux
The purpose of these instructions is to show how to automate ssh login and get a programmatic handle on the streaming data using Perl on Linux. The following instructions have been tested on a Debian distribution of Linux. If you have a different distribution of Linux it is possible that some of these instructions may need to be adopted.
Steps
As user root give the command:
apt-get install build-essentials
which will download and install several utilities. This is required to ensure that all pre-requisites for building and installation of CPAN modules are available.
Then give the command:
perl -MCPAN -e 'install Bundle::Expect'
which will build and install the Expect.pm Perl module along with all of its pre-requisites.
Then create a file: connect.pl
containing the following Perl code:
------------------------start code--------------------------
#! /usr/bin/perl
$| = 1;
use Expect;
$script = 'ssh -p 6174 rt01.demo@rt01.rtfxd.com';
$exp = new Expect;
$exp->spawn($script);
$password = "rtfxd";
#timeout
$t=5; #exit if there is no update in 5 seconds
$exp->expect($t,
#response to query:
[ 'Are you sure you want to continue connecting .*$' => sub {
$exp->send("yes\r");
exp_continue;
}
],
#response to password request:
[ 'password: $' => sub {
$exp->send("$password\r");
exp_continue;
}
],
#acknowledge receipt of timestamp line starting with character '@'
#this resets the timeout timer
[ '^@.*' => sub {
exp_continue;
}
]
)
------------------------end code----------------------------
If you have purchased Login Credentials:
Replace username: rt01.demo
password: rtfxd
in above code with the purchased credentials.