By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,280 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,280 IT Pros & Developers. It's quick & easy.

Connect to the remote machine using Telnet module

P: 8
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:
Expand|Select|Wrap|Line Numbers
  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 ' '");
  10.  
The flat file should look like the below one,

Windows,Administrator,Password
Linux,root,Password
Solaris,root,Password.



Regard's,
Thamayanthi.
May 8 '08 #1
Share this Question
Share on Google+
1 Reply


numberwhun
Expert Mod 2.5K+
P: 3,503
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:
Expand|Select|Wrap|Line Numbers
  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 ' '");
  10.  
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
May 8 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.