Hi,
I have a script which logins to many unix stations and executes a command and gets the output.
In some of the unix stations,it is not able to get the prompt after login and it times out.
I found out that the problem is due to,
login: xyz
Password:
Last login: Wed Apr 20 10:06:28 from arc54
10:09am up 112 day(s), 23:35, 7 users, load average: 0.14, 0.09, 0.06
arc55%
The problem is due to the the line appearing after the Last login info,ie the up time and users info.. The script is able to login to the machines where this info is not available.
Can any one let me know,how to make the script fail-proof. ie , make the script to waitfor the command prompt.
#!/usr/bin/perl
use lib '/usr/local/lib/perl5/site_perl/5.005/';
use Net::Telnet;
$telnet = new Net::Telnet( Timeout=>10,Errmode=>'die',Prompt=>'/[$%>#] $/i',Dump
_Log=>'/tmp/fail.log',Input_Log=>'/tmp/pass.log');
$telnet->open('arc55');
$telnet->login('tera','tera1');
$telnet->waitfor('arc55%');
sleep 5;
@outp = $telnet->cmd('/usr/sbin/psrinfo -v');
print @outp;
I have a script which logins to many unix stations and executes a command and gets the output.
In some of the unix stations,it is not able to get the prompt after login and it times out.
I found out that the problem is due to,
login: xyz
Password:
Last login: Wed Apr 20 10:06:28 from arc54
10:09am up 112 day(s), 23:35, 7 users, load average: 0.14, 0.09, 0.06
arc55%
The problem is due to the the line appearing after the Last login info,ie the up time and users info.. The script is able to login to the machines where this info is not available.
Can any one let me know,how to make the script fail-proof. ie , make the script to waitfor the command prompt.
#!/usr/bin/perl
use lib '/usr/local/lib/perl5/site_perl/5.005/';
use Net::Telnet;
$telnet = new Net::Telnet( Timeout=>10,Errmode=>'die',Prompt=>'/[$%>#] $/i',Dump
_Log=>'/tmp/fail.log',Input_Log=>'/tmp/pass.log');
$telnet->open('arc55');
$telnet->login('tera','tera1');
$telnet->waitfor('arc55%');
sleep 5;
@outp = $telnet->cmd('/usr/sbin/psrinfo -v');
print @outp;