LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-03-2006, 10:18 AM   #1
MikeAtVillage
Member
 
Registered: May 2005
Location: Mid Wales (UK)
Distribution: Slackware 8.0, Suse 10.0/1/2, CentOS (SMEServer7)
Posts: 38

Rep: Reputation: 15
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
 
Old 04-03-2006, 10:49 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,172
Blog Entries: 54

Rep: Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809Reputation: 2809
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
 
Old 04-03-2006, 11:16 AM   #3
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how does grub knows about existence of other OS? mohit_garg Linux - Newbie 29 07-13-2005 07:24 PM
Device existence problem..... roshu Mandriva 2 02-07-2005 06:01 AM
Scanner's temporal existence phantompgr Fedora 0 10-14-2004 06:51 PM
check for existence of file j-me Linux - Newbie 5 07-29-2003 07:58 AM
Checking Email from remote System Archangelkn Linux - Newbie 10 04-15-2002 07:32 PM


All times are GMT -5. The time now is 06:48 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration