The idea is simple, I want to be able to execute a command scpfrom my system and move files to another computer and vice versa.
In my case, there is a small problem. To connect to the destination computer, I need ssh on host_b first, and then ssh on host_c.
In short, I need to copy all my files to host_b first and then to host_c
This is scematic:
my_computer -> host_b -> host_c
Since, I have to do this in order to run my code manually each time, this becomes something frustrating, so I thought I had to make my own script to automate this process.
Here is my code:
echo
echo "Move files from your computer to HostC!"
echo
printf 'Username for hostB: '
read -r userB
hostb_addr='hostb.com'
printf 'Username for hostC: '
read -r userC
hostc_addr='hostc.com'
printf 'File you want to move: '
read -r filepath
scp_params='-P 8140'
spawn scp $scp_params $filepath $hostb_user@$hostb_addr:~/temp_transfer
interact
The main idea is to upload files from my computer to a temporary folder on hostB, copy them back to hostC again, and then delete the files from hostB.
, 'spawn not found'
: , bash