简体   繁体   English

使用bash脚本将树莓派的scp文件转换为mac文件

[英]scp files from raspberry pi to mac using bash script

I am trying to copy files from my raspberry pi to mac using a bash script. 我正在尝试使用bash脚本将文件从树莓派复制到Mac。 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 pi@192.168.0.101 ls -1 FlightLog* | sort -t_ -k2 -nr | head -1)
scp pi@192.168.0.101: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. 我也尝试过使用sftp命令,但遇到其他错误。 Does anybody know what is going on? 有人知道发生了什么吗? And what is the best way of copying files using a bash script? 使用bash脚本复制文件的最佳方法是什么?

EDIT: Found out why it was not working. 编辑:找出为什么它不起作用。 The correct scp format is: 正确的scp格式为:

scp pi@192.168.0.101:/home/pi/"$var" /Users/ykathur2/bin

I'd use rsync for better throughput; 我会使用rsync以获得更好的吞吐量; something like 就像是

rsync -mauvPAX pi@192.168.0.101:'~/FlightLog*' ykathur2@wirelessprv-10-192-192-127.near.illinois.edu:/Users/ykathur2/log/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM