[Hampshire] embedded expect

Top Page

Reply to this message
Author: Damian Brasher
Date:  
To: hampshire
Subject: [Hampshire] embedded expect
Hi List

I am trying to embed an expect routine into a script using the 'HERE' tag
( << EOF) to automate some processes on a machine over ssh, this is my
first attempt, as you can see I have used a config file and some
environment variables are pulled in:

Can anyone check the syntax of this - something is wrong as it appears the
login does not work and hence the test command not executed?

I have used http://bash.cyberciti.biz/security/sshlogin.exp.php as a
reference, but decided I needed more than the expect 'set' variable, as
well as the expect man page after building expect from source, the source
requires Tcl to build but not to run, the platform can be chosen by
switches at build time:

#!/bin/bash

. .config.sh

./expect << EOF
spawn ssh root@$IP_ADD_A 'ls > junk'
expect "*?assword:*"
send -- "$ROOT_PASS_A\r"
send -- "\r"
expect eof

EOF

TIA Damian
--
Damian Brasher
www.diap.org.uk "Aim to protect mission critical data: 'You can't afford
to loose...'"

All mail scanned by clam-av http://www.clamav.net/