Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-16-2005, 12:07 PM   #1
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Rep: Reputation: 30
telnet server not reliable for expect script

I installed telnet server on FC3.
"disable = no" is set in

Use xinetd to start telnet
$ /etc/init.d/xinetd restart

"telnet localhost" always work manually.
I wrote an expect script to automate telnet does not work most of the time in this machine but
always work in another machine.

The expect script is:

proc info_print { str} {
send_user " ++++++++++++++++++++++++++++++++++++++++++++++++++++++"
send_user " $str"
send_user " ++++++++++++++++++++++++++++++++++++++++++++++++++++++"

proc run_remote { {server} {user} {pass} {params} } {
set timeout 60
set res [spawn telnet $server]
expect "login:" { send "$user\r" }
sleep 5
expect "Password:" { send "$pass\r" }

expect {
"Last login" {
info_print " "
info_print "..Connected ! "
sleep 0.5
"Login failed" {
info_print "**FAILED** to TELNET to $server using ($user,$pass) "

info_print "sudo $params"
send "sudo $params\r"
expect {
"Capturing" {
info_print "Starting capture .. "
expect {
"$user@" { info_print "Capture complete..! "}

run_remote localhost john john "/usr/sbin/tethereal -i ath0 -c 1 -w /tmp/sniff.capture"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect Script coolest Programming 7 02-16-2009 04:59 PM
cron job for expect script ruchitadesai Programming 9 05-27-2005 05:34 AM
trying to execute an expect script in .bashrc smaudlin Red Hat 2 01-02-2005 02:34 AM
BAD SU- from a cronned expect script ganninu Linux - General 1 07-18-2004 11:49 AM
Automae telnet log in and execute commands (expect and send) rajatgarg Linux - Networking 0 06-24-2004 12:37 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:46 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration