The idea is simple, I want to be able to execute the scp command from my system and move files to another computer and vice versa.
My case has a small problem. In order to connect to the end computer I have to first ssh to a host_b and then ssh to host_c.
Long story short, I have to copy all my files to host_b first and then to host_c
This is the scematic:
my_computer -> host_b -> host_c
Since, I have to do this in order to run my code manually every time, it's getting kinda frustrating, So I thought that I should make my own script to automate this process.
Here's my code so far:
#!/usr/bin/expect -f
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'
# connect via scp to hostB
spawn scp $scp_params $filepath $hostb_user@$hostb_addr:~/temp_transfer
interact
The main idea is to get the files from my computer to a temporary folder to hostB, scp them again to hostC and then delete the files from hostB.
I've started trying to make this work but I'm getting a 'spawn command not found'
NOTE: this is actually the first time i've used bash