我写了一个脚本,它会压缩一个文件夹,然后再存储它。到目前为止,这工作得很好。但现在我想使用 scp 发送它。我想使用 eval 以便可以轻松更改它们。但是当我使用它将文件发送到某个目的地时,它总是告诉我该目录或文件不存在。如果我在没有 $scriptd 的情况下这样做,那么它就像一个魅力。
任何想法为什么?
#!/bin/bash
# Implementation of variables
today=$(date +"%Y-%m-%d")
source="~/Documents"; eval source=$source
target="~/Backups"; eval target=$target
scriptd="~/Documents/Backups"; eval scriptd=$scriptd
main(){
backup
}
backup(){
tar -zvcf $today.tar.gz -P $source
rsync -zhap --progress $scriptd/$today.tar.gz $target
rm $scriptd/$today.tar.gz
scp $target/$today.tar.gz pi@I-Am-An-IP:$scriptd
}
main
exit 0