Re: Scripting: Check existence of file on remote system

From: Green, Simon (SGreen@KRAFTEUROPE.COM)
Date: Mon Jul 22 2002 - 12:42:19 EDT


The presence of the file just indicates that a certain application is
running, (or at least: hasn't been shutdown normally). I could do "ps
-ef|grep <application program>" instead, but checking for the file is easier
as there are a bunch of similar programs which could be running and which
I'm not interested in, so I'd have to make it a much more complicated test.

It's not terribly difficult to do; I was just hoping someone might know of a
tidier way to do it. Embedding ifs is no worse than ls|grep, but it's no
better, either.

The best I've come up with so far is...

rsh server ls /filename | grep -q filename && Do Stuff

   ...which I suppose is OK, it just strikes me as clumsy and doesn't meet
my high aesthetic standards. :-)

Simon Green
Philip Morris ITSC Europe

AIX-L Archive at http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2
AIX FAQ at http://www.faqs.org/faqs/aix-faq/

N.B. Unsolicited email from vendors will seldom be appreciated.

> -----Original Message-----
> From: Paul LaMadeleine [mailto:plamadeleine@LIGHTBRIDGE.COM]
> Sent: 22 July 2002 17:07
> To: aix-l@Princeton.EDU
> Subject: Re: Scripting: Check existence of file on remote system
>
>
> How about something like this:
>
> if [ `rsh "if [ -f <filename> ]; then echo 0; else echo 1;
> fi"` -eq 0 ]
> then
> # do what ever actions you need to do here
> echo file found on remote server
> else
> # do some other commands here
> echo file not found on remote server
> fi
>
> Why do you need to check for the existence of the file? This
> may help in
> doing some coding.



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:05 EDT