Im trying to make a script to automate ssh login and download of a file for multiple ip addresses that are kept in a file, im using a for i in $(cat /dir/file)
, problem is the cat function is working in expect so i cant use it on a script that is interpreted with expect.
I wanted to know if it is possible to make half of the script be interpreted by bash and the other half by expect like this
#!/bin/bash
code........
#!/usr/bin/expect
code........
my code now looks like this
#!/bin/bash
expect <<-EOF
spawn sftp user@server
expect "*password:" { send "password\r" }
expect "*" { send "get /home/file\r" }
expect "*" { send "bye\r" }
EOF
i get this response now
spawn sftp user@server
user@server´s password: user@hostname: /home/user
basically it return to the normal terminal state