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

telnet script?

Status
Not open for further replies.

koeicjm

Programmer
Sep 12, 2001
73
JP
how can I write a script for login a remote server using telnet , and to do sth at there.
 
There is a utility called "expect" which you can use to do this. Alternatively there is a telnet module for Perl which does the same job.

What is 'sth'? If it is a particular command you'd like to run you might consider using rcmd instead. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
I try to install expect from freebsd 's pkg, but when I try to use it,wright a script :
#! /bin/sh
spawn telnet 192.168.1.16
expect "User:"
send <jchen\r>
expect &quot;Password:&quot;
send <winner\r>
interact

Is it right, I got error &quot;spawn: not found&quot;
but I really didnot know where can I find it ,
and what is it? What should I do ?
I only want use the script to login remote server,
using tar to expand a tar file and login root
to exceute a shell.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top