||10-09-2012 10:08 AM
using expect in bash for multiple independent commands
I have a bash script which will run multiple commands against 35-50 remote systems. I cannot use RSA keys (yet). ONE of the jobs of the script is to install my public key on these systems (I have the root passwords for all of them).
The script successfully uses expect with ssh
to login and create the .ssh directory, but the expect for the next command, scp, does not run at all
. I have turned on exp_internal 1 and I get no output from it. It's as if the expect is ignoring the spawn. (The $cpyparms is properly expanded with lvm being expanded too, before the 2nd expect is started)
Here is the relevant portion of my script:
echo "creating sshdir on" $id
VAR=$(/usr/local/bin/expect -c "
spawn ssh $user@$lvm $cmd1
echo "#---- copying sshkey from myself ----#"
spawn scp $cpyparms