I want to automate a scp command like the following:
scp [email protected]:/home/pi/remote/\{aaainremote,bbbinremote,cccinremote\} /home/pi/local
The above command works as expected when entered in a terminal.
The following is a condensed version of my bash script named cwmscp:
The variables are named as arguments in the full script, but simplified here as shown.
filename1=“aaainremote”
filename2=“bbbinremote”
file names=“cccinremote”
ipaddress=“192.168.1.100”
source=“/home/pi/remote/“
destination=“/homepi/local”
scp pi@$ipaddress:$source\{filename1,filename2,filename3\} $destination
When I execute the bash script, I get the password prompt for the remote system and I enter the password.
The first file, aaainremote is copied, but not the bbbinremote or cccinremote.
I can change the order of the three file names and only the first file named is copied
I get the the following output:
[email protected]’s password: (I enter the password)
aaainremote. 100% 4. 6.9KB/s. 00:00
scp: /home/pi/remote: not a regular file
scp: /home/pi/remote: not a regular file
The three files are identical test files with different names:
Only the first file named in the scp command gets copied.
I can manually type the following in a terminal session and all three files get copied as expected:
scp [email protected]:/home/pi/remote/\{aaainremote,bbbinremote,cccinremote\} /home/pi/local
scp [email protected]:/home/pi/remote/\{aaainremote,bbbinremote,cccinremote\} /home/pi/local
The above command works as expected when entered in a terminal.
The following is a condensed version of my bash script named cwmscp:
The variables are named as arguments in the full script, but simplified here as shown.
filename1=“aaainremote”
filename2=“bbbinremote”
file names=“cccinremote”
ipaddress=“192.168.1.100”
source=“/home/pi/remote/“
destination=“/homepi/local”
scp pi@$ipaddress:$source\{filename1,filename2,filename3\} $destination
When I execute the bash script, I get the password prompt for the remote system and I enter the password.
The first file, aaainremote is copied, but not the bbbinremote or cccinremote.
I can change the order of the three file names and only the first file named is copied
I get the the following output:
[email protected]’s password: (I enter the password)
aaainremote. 100% 4. 6.9KB/s. 00:00
scp: /home/pi/remote: not a regular file
scp: /home/pi/remote: not a regular file
The three files are identical test files with different names:
Only the first file named in the scp command gets copied.
I can manually type the following in a terminal session and all three files get copied as expected:
scp [email protected]:/home/pi/remote/\{aaainremote,bbbinremote,cccinremote\} /home/pi/local