Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

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 )
  1. $Machine="192.168.**.**";
  2. $user="UserName";
  3. $pwd="Password";
  4. $telnet->open($Machine);
  5. $telnet->waitfor('/login:/');
  6. $telnet->print($user);
  7. $telnet->waitfor("/Password for $user:/");
  8. $telnet->print($pwd))
  9. 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).
numberwhun's Avatar
numberwhun
Forum Leader
1,860 Posts
May 8th, 2008
10:49 AM
#2

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 )
  1. $Machine="192.168.**.**";
  2. $user="UserName";
  3. $pwd="Password";
  4. $telnet->open($Machine);
  5. $telnet->waitfor('/login:/');
  6. $telnet->print($user);
  7. $telnet->waitfor("/Password for $user:/");
  8. $telnet->print($pwd))
  9. 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

Reply
Reply
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