如何检查是否DIR通过SSH存在,并返回结果到主机机 [英] How to check if dir exist over ssh and return results to host machine
本文介绍了如何检查是否DIR通过SSH存在,并返回结果到主机机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图建立SSH连接,看看是否一个目录中,如果该目录存在,我想运行在本地机器做出的SSH呼叫命令。
I'm trying to establish an SSH connection and see if a directory exist, and if that directory exists I want to run commands on the local machine that made the SSH call.
下面是我已经尝试:
if [ ssh -t username@ssh_server -d /directory ]
then
{
commands....
}
fi
是这样的可能吗?
Is something like this possible?
推荐答案
您是非常接近:
更改if语句
if (ssh username@ssh_server '[ -d /directory ]')
我假设你已经设置基于密钥的验证。
I am assuming that you have setup key-based authentication.
这篇关于如何检查是否DIR通过SSH存在,并返回结果到主机机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文