Reputation: 7
This Expect script is a part of my UNIX Bash script
expect -c "
spawn scp [email protected]:\"encryptor *.enc\" .
expect password: { send \"$PASS\r\" }
expect 100%
sleep 1
exit
"
I am trying to copy both 'encryptor' and '*.enc' with this one SCP command. Console tells me it cannot find ' *.enc" '
Upvotes: 0
Views: 8850
Reputation: 21
Not sure it helps but I was looking for a similar objective.
Means: Copying some selected files based on their filenames / extensions but located in different subfolders (same level of subfolders).
this works e.g. copying .csv files from Server:/CommonPath/SpecificPath/
scp -r Server:/CommonPath/\*/\*csv YourRecordingLocation
I even tested more complex "perl like" regular expressions.
Not sure the -r
option is still useful.
Upvotes: 2
Reputation: 16446
#!/bin/bash
expect -c "
set timeout 60; # 1 min
spawn scp [email protected]:{encryptor *.enc} .
expect \"password: $\"
send \"mypassword\r\"
expect eof
"
You can increase the timeout
if your file copy takes more time to complete. I have used expect eof
which will wait till the closure of the scp
command. i.e. we are waiting for the End Of File (EOF) of the scp
after sending the password.
Upvotes: 1
Reputation: 4012
The syntax for multiple files:
$ scp [email protected]:~/\{foo.txt,bar.txt\} .
I would guess in your case (untested)
scp [email protected]:\\{encryptor, \*.enc\\} .
Upvotes: 2