Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-08-2002, 08:00 AM   #1
Registered: May 2002
Location: Shanghai, PRC
Distribution: RedHat 6.2 | 7.2 | 8 | 9|3
Posts: 81

Rep: Reputation: 15
Angry "expect" shell beginner question, please help me out

Hi all,

I am a TCL/TK expect shell learner. I'm in trouble now. I wrote an EXPECT shell which can help me to "ssh" to 100 RedHat boxes to do the same work. Actually I just wanna change "root" password for them. But I found it stop working when "SSH" to some boxes, maybe for this reason or that reason. Anyway, my shell just stop where it is. What I hope is if my EXPECT shell can skip the error point and go on with its mission. Don't stop working just because one machine is not compatible with my shell.
In addition to that, I wonder if EXPECT shell can display an error message to say that which one could not be finished.
The following lines are one section of my shell. In fact, I have aother 99 similar sections...
set timeout -1
spawn ssh
match_max 100000
expect "'s password: "
sleep 1
send -- "old_password\r"
expect "root\]# "
sleep 1
send -- "passwd\r"
expect " password: "
sleep 1
send -- "new_password\r"
expect " password: "
sleep 1
send -- "new_password\r"
expect "root\]# "
send -- "exit\r"
expect eof

Old 06-28-2003, 02:17 PM   #2
LQ Newbie
Registered: Jun 2003
Posts: 1

Rep: Reputation: 0

# Created by mearls
# Hosts are valid ip or dns name of the device
# Set value of $Script to the expect script you would like to run
# Script needs to be in the same directory or change the path below

@hosts = qw(



for $host (@hosts) {

print "\nRunning $Script on $host...\n";

open(SWITCH, "/usr/bin/expect ./$Script $host 2> /var/log/test.log |");

print "Completed $host. \n";

Then i would create the expect shell script.

to run the script chmod 755 ./name

if there are issues it should log to /var/log/test.log


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 05:08 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM
No UTMPX entry, You must EXEC "login" for the lowest "shell" ooihc Solaris / OpenSolaris 7 03-12-2007 03:09 PM
shell question: the "mv" command with multiply files basher400 Linux - Newbie 4 12-19-2005 08:42 AM
Expect script throws "open(slave pty): bad file number" error KNut Linux - Newbie 0 02-24-2004 01:24 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:31 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration