Simon reap wrote:
> On Sat, Oct 13, 2007 at 07:37:23PM +0100, Damian Brasher wrote:
>>>> ./expect << EOF
>>>> spawn ssh root@$IP_ADD_A 'ls > junk'
>>>> expect "*?assword:*"
>>>> send -- "$ROOT_PASS_A\r"
>>>> send -- "\r"
>>>> expect eof
>>>>
> I use expect all the time to log in to ssh sites (with passwords or
> passkeys, as appropriate)
>
> The problem is probably the pattern for password - remember that expect
> expects to search within strings, so you don't need the '*' bits. you
> could use something like:
>
> ROOT_PASS=fred
> expect <<EOF
> spawn ssh root@$IP_ADD_A ls > junk
> expect 'assword:'
> send -- "$ROOT_PASS\r"
> expect eof
> EOF
I used a combination of:
. .config.sh
./expect << EOF
spawn scp expect $USER_ACC@$IP_ADD_A:expect
expect "assword:"
send -- "$USER_PASS\r"
expect eof
EOF
and...
. .config.sh
./expect << EOF
spawn scp .ssh/local.key diap@$IP_ADD_C:key_from_a
expect "(yes/no)?"
sleep 0.2
send -- "yes\r"
expect "assword:"
send -- "$USER_PASS\r"
expect eof
EOF
Where I expected (no pun intended) the host to be authenticated, (yes/no)?
etc.
Really smooth once you do the reverse engineering of ssh and the commands
you want to execute. I would like to understand forking a little more so
may purchase the book you recommended. It's not Voodoo (much;)
Thanks again
Damian
--
Damian Brasher
www.diap.org.uk "Aim to protect mission critical data: 'You can't afford
to lose...'"
All mail scanned by clam-av
http://www.clamav.net/