检查文件是否使用ssh远程主机上存在 [英] check if file exists on remote host with ssh
本文介绍了检查文件是否使用ssh远程主机上存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要检查,如果某个文件在远程主机上存在。
我想这样的:
$如果[SSH章@本地-p 19999 -e /home/reg/Dropbox/New_semiosNET/Research_and_Development/Puffer_and_Traps/Repeaters_Network/UBC_LOGS/log1349544129.tar.bz2 ],然后回声okidoke否则不好啦!科幻
-SH:语法错误:意外的其他(期待然后)
解决方案
有关这个问题的答案是无处不在。下面是一个简单的方法。
如果SSH $ HOST统计$ FILE_PATH \\>的/ dev / null的2 \\> \\&放大器; 1
然后
回声文件存在
其他
回声文件不存在科幻
I would like to check if a certain file exists on the remote host. I tried this:
$ if [ ssh reg@localhost -p 19999 -e /home/reg/Dropbox/New_semiosNET/Research_and_Development/Puffer_and_Traps/Repeaters_Network/UBC_LOGS/log1349544129.tar.bz2 ] then echo "okidoke"; else "not okay!" fi
-sh: syntax error: unexpected "else" (expecting "then")
解决方案
Answers for this question are everywhere. The following is a simple approach.
if ssh $HOST stat $FILE_PATH \> /dev/null 2\>\&1
then
echo "File exists"
else
echo "File does not exist"
fi
这篇关于检查文件是否使用ssh远程主机上存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文