LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-08-2002, 07:00 AM   #1
yuzuohong
Member
 
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 1.2.3.4
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
=======================================

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

Rep: Reputation: 0
#!/usr/bin/perl

#
# Created by mearls
# post_message@vermeer.org
#
# 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(
server1
server2
server3

);

$Script="password.exp";

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";
close(switch);
}

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
 
  


Reply


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 04:08 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
No UTMPX entry, You must EXEC "login" for the lowest "shell" ooihc Solaris / OpenSolaris 7 03-12-2007 02:09 PM
shell question: the "mv" command with multiply files basher400 Linux - Newbie 4 12-19-2005 07:42 AM
Expect script throws "open(slave pty): bad file number" error KNut Linux - Newbie 0 02-24-2004 12:24 PM


All times are GMT -5. The time now is 02:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration