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
1#!/usr/bin/expect -f
2
3## Set variables here
4## JSS parameters are -1
5
6set user [lindex $argv 2]
7set host [lindex $argv 3]
8set password *putpasswordhere*
9set path1 [lindex $argv 5]
10set path2 [lindex $argv 6]
11set path3 [lindex $argv 7]
12set path4 [lindex $argv 8]
13set path5 [lindex $argv 9]
14set path6 [lindex $argv 5]
15
16spawn scp -r $path1 root@$host:/Volumes/Storage/sftp/$user/
17expect {
18 "*?word:" {
19 send "$password
20"
21 exp_continue
22 }
23}
24
25spawn scp -r $path2 root@$host:/Volumes/Storage/sftp/$user/
26expect {
27 "*?word:" {
28 send "$password
29"
30 exp_continue
31 }
32}
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)?"