Connect to the remote machine using Telnet module
Question posted by: thamayanthi
(Newbie)
on
May 8th, 2008 07:03 AM
Hi,
Please find the below code which is used to Print the Operating System of a remote Machine of linux.This code is working fine,if i give the correct UserName and Password of a machine but what i need is if iam having set of UserName and Password in a flat file and the code should check if it matches with any of this set of UserName and Passwords and execute the code without throwing any error like (command timed-out at linux.pl line 98).please help in this........
Code:
Code: ( text )
$Machine="192.168.**.**"; $user="UserName"; $pwd="Password"; $telnet->open($Machine); $telnet->waitfor('/login:/'); $telnet->print($user); $telnet->waitfor("/Password for $user:/"); $telnet->print($pwd)) print $telnet->cmd("uname -a|tr -s ' '|cut -f1 -d ' '");
The flat file should look like the below one,
Windows,Administrator,Password
Linux,root,Password
Solaris,root,Password.
Regard's,
Thamayanthi.
Last edited by numberwhun : May 8th, 2008 at 10:45 AM.
Reason: Please use code tags!
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Re: Connect to the remote machine using Telnet module
Quote:
Originally Posted by thamayanthi
Hi,
Please find the below code which is used to Print the Operating System of a remote Machine of linux.This code is working fine,if i give the correct UserName and Password of a machine but what i need is if iam having set of UserName and Password in a flat file and the code should check if it matches with any of this set of UserName and Passwords and execute the code without throwing any error like (command timed-out at linux.pl line 98).please help in this........
Code:
Code: ( text )
$Machine="192.168.**.**"; $user="UserName"; $pwd="Password"; $telnet->open($Machine); $telnet->waitfor('/login:/'); $telnet->print($user); $telnet->waitfor("/Password for $user:/"); $telnet->print($pwd)) print $telnet->cmd("uname -a|tr -s ' '|cut -f1 -d ' '");
The flat file should look like the below one,
Windows,Administrator,Password
Linux,root,Password
Solaris,root,Password.
Regard's,
Thamayanthi.
|
I am not sure that I totally understand what you are looking for. Are you wanting to connect through telnet with a username/pwd, then grab the OS type and then compare if the username/pwd/os combination matches what you have in a local flat file?
Regards,
Jeff
 |
Not the answer you were looking for? Post your question . . .
184,013 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).
|
|
|
Latest Articles: Read & Comment
Top Perl Forum Contributors
|