Remove both ' from the variable. If you have spaces and such and don't want to deal with backslashes you could always use double quotes (") instead.
That worked. Now the script just exits and never passes the password with the expect.
Have you tried just putting the entire script in expect?
!/usr/bin/expect -f
Or is this part of a greater script? I've never really worked with expect calls within another script so I'm not sure if anything else is necessary.
In any event, the guy in this link is attempting to do something similar and someone uses a similar script to yours but appends:
expect "
"
send "
"
After the password send. Not sure what's happening there exactly but worth a shot.
http://serverfault.com/questions/209248/can-i-use-expect-with-scp-to-bypass-the-password-prompt
Tried using the /usr/bin/expect
#!/usr/bin/expect -f
## Set variables here
## JSS parameters are -1
set user [lindex $argv 2]
set host [lindex $argv 3]
set password *putpasswordhere*
set path1 [lindex $argv 5]
set path2 [lindex $argv 6]
set path3 [lindex $argv 7]
set path4 [lindex $argv 8]
set path5 [lindex $argv 9]
set path6 [lindex $argv 5]
spawn scp -r $path1 root@$host:/Volumes/Storage/sftp/$user/
expect {
"*?word:" {
send "$password
"
exp_continue
}
}
spawn scp -r $path2 root@$host:/Volumes/Storage/sftp/$user/
expect {
"*?word:" {
send "$password
"
exp_continue
}
}
The path variables are not able to use the $user in the parameter and you have to type in the username .
like /Users/username/path/to/folder/
I would like it to be /Users/$user/path/to/folder/
This may sound dumb... but have you tested it in non-script form? Are you maybe getting an ECDSA key fingerprint warning?
That would bring up this query and maybe interfere with your expect:
"Are you sure you want to continue connecting (yes/no)?"