1. 程式人生 > >用shell判斷遠程主機上是否存在某個文件

用shell判斷遠程主機上是否存在某個文件

shell

在遠程主機10.162.134.203上是存在/home/scopsadm/scripts/changePassword/changePassword.sh腳本文件的:

[[email protected] ~]$ if ssh -i ~/.ssh/scopsadm_rsa [email protected] test -e /home/scopsadm/scripts/changePassword/changePassword.sh; then echo Ok; else echo Bad; fi
Ok


在遠程主機10.162.134.203上是不存在/home/scopsadm/scripts/changePassword/test.sh這個文件的:

[[email protected] ~]$ if ssh -i ~/.ssh/scopsadm_rsa [email protected] test -e /home/scopsadm/scripts/changePassword/test.sh; then echo Ok; else echo Bad; fi
Bad
[[email protected] changePasswd]$


本文出自 “不積跬步,無以至千裏” 博客,請務必保留此出處http://jiaxiaolei.blog.51cto.com/3117381/1948253

用shell判斷遠程主機上是否存在某個文件