LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   using expect scripts for remote admin (https://www.linuxquestions.org/questions/linux-general-1/using-expect-scripts-for-remote-admin-136780/)

jmr71769 01-20-2004 02:00 PM

using expect scripts for remote admin
 
hello everyone.

i've read the expect pages up and down (aka man expect). and while i've gained basic knowledge of the tool, i'm a bit stuck with an advanced topic.

my mission:

to remote admin multiple debian boxes and update them using a simple script.

there are 10 boxes, so this script would be something like:

while $i [box1name box2name box3name etc...]

send "ssh -l root $i"
expect "pass"
send "<passphrase>"
expect "~#"
send "apt-get update"
sleep 2
send "apt-get upgrade -y"
"sleep 2"
goto nextbox ;
exit

again, i am by no means a scripting/expect master, i would greatly appreciate some insight on this. i've searched google high and low, and yes even played with autoexpect but it didn't quite return the results desired.

thanks all.

david_ross 01-20-2004 02:11 PM

Take a look at my LinuxAnswer on ssh and public key authentication. You should be able to do this without an expect script which will should save you time.

jmr71769 01-20-2004 02:28 PM

thank you david
 
i thought your article was great... but... i'm still wondering, how does this take care of logging sequentially into 10 different machines and performing said tasks without actually being (t)here?

that's the part i'm missing. wouldn't i need a script to perform all the ssh'ing and apt-get'ing?

thank you again

david_ross 01-21-2004 01:27 PM

You probably will need a script to perform the installations but you shouldn't need an expect script to connect.

You could use a command like:
ssh root@server.yourdomain.com "wget -qO - http://www.yourdomain.com/update.sh | sh"

This will then download and execute your update.sh script from your webserver.


All times are GMT -5. The time now is 01:20 AM.