Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! need to write script that tel

Status
Not open for further replies.

g1itch

IS-IT--Management
Sep 4, 2002
13
US
HELP! need to write script that telnets into a switch, router, etc checks status and gets out. how do I write a script that will telnet into a device and exit. any help is appreciated. thanks. [morning]
 
'expect' is your friend. vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Try expect programming.

It will look something like this:

#!/usr/local/bin/expect

spawn telnet <ip_switch>
sleep 3


expect &quot;Username:&quot; ## or what it prompts you
send &quot;<user>\r&quot;

expect &quot;Password:&quot;
send &quot;<password>\r&quot;

expect &quot;<switch_prompt>&quot;
send &quot;<status_command>\r&quot; EDC
--------------------------------------
This is Unix-Land. In quiet nights, you can hear the Windows machines
reboot.
 
thnx will check it out and give a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top