I have the following script running successfully. However if I try to use a wildcard, to copy multiple files, it throws an error, saying “No such file or directory”.
This code works:
#!/usr/bin/expect -f
spawn scp file1.txt root@192.168.1.156:/temp1/.
expect "password:"
send "iamroot\r"
expect "*\r"
expect "\r"
The following doesn’t work:
#!/usr/bin/expect -f
spawn scp * root@192.168.1.156:/temp/. #fails here
….
The
*is usually expanded by the shell (bash), but in this case you shell isexpect. I suspect thatexpectis not expanding the*.try:
explanation: