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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto telnet

Status
Not open for further replies.

3wsparky

IS-IT--Management
May 25, 2003
121
GB
anyone have a good free app that you can use to automate telnet so you can simply create a .bat file and do a autotelnet "ip" which will submit your username and password at the right time ,also run one or two commands once you have logged in ?
 
Have you looked into expect scripts? Very easy to do. If interested let me know. Im pretty sure I have some stored somewhere.

Free Firewall/Network/Systems Support-
 
i downloaded a version of this but didnt seem to be able to get it to work , what info do you have on the product ?
 
You downloaded expect? If using on a windows platform I would recommend using cygwin and choose the expect package.

Here is a basic telnet example using expect:


Code:
#!/usr/bin/expect #Where the script should be run from.


set timeout 20 #If it all goes pear shaped the script will timeout after 20 seconds.

set name [lindex $argv 0] #First argument is assigned to the variable name

set user [lindex $argv 1] #Second argument is assigned to the variable user

set password [lindex $argv 2] #Third argument is assigned to the variable password


spawn telnet $name #This spawns the telnet program and connects it to the variable name


expect "login:" #The script expects login

send "$user " #The script sends the user variable

expect "Password:" #The script expects Password

send "$password " #The script sends the password variable

interact #This hands control of the keyboard over two you (Nice expect feature!)

Pulled from:
To use this script you would execute from command line. You also want o make the script executable.

touch telnet.sh
vi telnet.sh
Paste the script into the telnet.sh file
Type the following :wq! [enter]
chmod 777 telnet.sh
./telnet.sh 192.168.0.5 Username P@ssw0rd





If you don't want the interact you can continue with the expect command and send router/firewall commands using "send". The output can also be placed in a file. What exactly are you trying to achieve?

I have some ssh scripts if needed.





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top