LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-16-2005, 11:07 AM   #1
powah
Member
 
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
/etc/xinetd.d/telnet

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:
#!/usr/bin/expect

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) "
exit
}
}

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"
 
  


Reply



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 03:59 PM
cron job for expect script ruchitadesai Programming 9 05-27-2005 04:34 AM
trying to execute an expect script in .bashrc smaudlin Red Hat 2 01-02-2005 01:34 AM
BAD SU- from a cronned expect script ganninu Linux - General 1 07-18-2004 10:49 AM
Automae telnet log in and execute commands (expect and send) rajatgarg Linux - Networking 0 06-24-2004 11:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:23 PM.

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