S
siddhartha mulpuru
I use this NET::TELNET module to login into a telnet session.. THis is
the code
#!/usr/bin/perl
use CGI;
$frm = new CGI;
$unix_box = $frm->param('unix_box');
$username = $frm->param('username');
$password = $frm->param('password');
#$unix_box = "xxxx.xxx.xxx";
#$username = "xxxxxx";
#$password = "xxxxxxxx";
my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/';
$telnet = new Net::Telnet ( Timeout=>20, Prompt => $prmpt,
"Dump_log" => "dump_log",
Errmode=>'die');
use Net::Telnet;
$telnet->open($unix_box);
$telnet->waitfor('/login:/i');
$telnet->print($username);
$telnet->waitfor('/Enter SecurID PASSCODE:/i');
$telnet->print($password);
$telnet->waitfor('/.+:\/.+\/.+>/i');
@lines= $telnet->cmd("who");
#print STDOUT @lines;
print "Content-type: text/html\n\n";
print "
@lines
";
$telnet->close;
When i run this script from the command line it works fine. But when i
run this as a post from a form with values for username,password and
unix box it does not work.
Please advise
Thanks
Sid
the code
#!/usr/bin/perl
use CGI;
$frm = new CGI;
$unix_box = $frm->param('unix_box');
$username = $frm->param('username');
$password = $frm->param('password');
#$unix_box = "xxxx.xxx.xxx";
#$username = "xxxxxx";
#$password = "xxxxxxxx";
my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/';
$telnet = new Net::Telnet ( Timeout=>20, Prompt => $prmpt,
"Dump_log" => "dump_log",
Errmode=>'die');
use Net::Telnet;
$telnet->open($unix_box);
$telnet->waitfor('/login:/i');
$telnet->print($username);
$telnet->waitfor('/Enter SecurID PASSCODE:/i');
$telnet->print($password);
$telnet->waitfor('/.+:\/.+\/.+>/i');
@lines= $telnet->cmd("who");
#print STDOUT @lines;
print "Content-type: text/html\n\n";
print "
@lines
";
$telnet->close;
When i run this script from the command line it works fine. But when i
run this as a post from a form with values for username,password and
unix box it does not work.
Please advise
Thanks
Sid