Reputation: 61
I am trying to copy files from my raspberry pi to mac using a bash script. I was able to find the relevant files and I checked to ensure my directories were correct. Here is my script:
#!/bin/bash
var=$(ssh [email protected] ls -1 FlightLog* | sort -t_ -k2 -nr | head -1)
scp [email protected]:home/pi/"$var" ykathur2@wirelessprv-10-192-192-
127.near.illinois.edu/Users/ykathur2/bin
And here is the error I got:
Shared connection to 192.168.0.101 closed.
scp: home/pi/FlightLog_89.dat: No such file or directory
I have also tried using sftp
command and I got other bugs. Does anybody know what is going on? And what is the best way of copying files using a bash script?
EDIT: Found out why it was not working. The correct scp
format is:
scp [email protected]:/home/pi/"$var" /Users/ykathur2/bin
Upvotes: 1
Views: 531
Reputation: 3249
I'd use rsync for better throughput; something like
rsync -mauvPAX [email protected]:'~/FlightLog*' [email protected]:/Users/ykathur2/log/
Upvotes: 1