LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Checking existence on remote server (https://www.linuxquestions.org/questions/programming-9/checking-existence-on-remote-server-431340/)

MikeAtVillage 04-03-2006 10:18 AM

Checking existence on remote server
 
Hi,

How can I check the existence of a file or a directory on a remote server ?

I though it would be the following but it's obviously not quite right :-)

if [ ! -d 172.16.15.9:/home/mike ] ; then.......


Thanks

Mike

unSpawn 04-03-2006 10:49 AM

There's prolly "better" solutions, but this file example does work:
res=($(lynx -dump -head proto://fqdn/file | grep -m1 "^HTTP/"))
case "${res[1]:0:1}" in 1|2) echo Got it;; 3) echo Look somewhere else;; 4|5|*) echo Aint got it;; esac

lackluster 04-03-2006 11:16 AM

You can do something like

ssh host perl -e 'print ((-f /tmp/file) ? "true" : "false");'

But
A.) That syntax may be a bit off
B.) You'd have to setup non-password SSH access to host


All times are GMT -5. The time now is 03:43 PM.