I have a script below that works except for the expect portion:
#!/bin/bash
#
invdir=/home/john/inventory
for file in $invdir/$1
do
if [ -z $1 ] || [ -z $2 ]
then
echo "You must enter a value: prod, dev, dr, or test AND the password of the env you entered"
exit 0
else
for host in `cat $file`
do
ssh-copy-id -i ~/.ssh/id_rsa.pub $host <<-EOF
expect "password:"
send "$2\n"
EOF
done
fi
done
I found an expect script that does most of what I need:
#!/usr/bin/expect -f
spawn ssh-copy-id $argv
expect "password:"
send "your_password\n"
expect eof
to execute ./expect_script user@host1
My problem is that I don't know enough of either bash or expect to get these two to work under one bash script or expect script.
Thank you in advance....