2011-12-01 70 views

回答

9

这个怎么样?

ssh [email protected] 'if [ -f /path/to/my/file.txt ]; then echo yes; else echo no; fi' 
+0

我发现了一些这样的事情,但这个工作非常好。我发现我的错误。我使用ssh user @ host:/ path/to/my /'if [-f file.txt]; ...这不工作:) – Rodrigo

3

像这样的东西能帮助 -

ping -c 1 ipaddress && ssh [email protected] 'test -e /path/and/filename && echo exists' 
+0

工作。再详细一点:) – Rodrigo

+0

为什么要先ping? – Sorpigal

+0

只是为了检查主机是否启动。 –

0
ssh serverName 

test -e 
echo $? 
相关问题