Re: Scripting: Check existence of file on remote system

From: Paul LaMadeleine (plamadeleine@LIGHTBRIDGE.COM)
Date: Mon Jul 22 2002 - 12:07:25 EDT


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.

         Hope this helps,

         Paul

At 05:46 PM 7/22/2002 +0200, you wrote:
>That'll work, but I still need to put a grep in the script in order to take
>action, so it's not really any better than an ls|grep.
>
>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: Bruce Zimmer [mailto:b.r.zimmer@WORLDNET.ATT.NET]
> > Sent: 22 July 2002 15:47
> > To: aix-l@Princeton.EDU
> > Subject: Re: Scripting: Check existence of file on remote system
> >
> >
> > Try using
> >
> > rsh "if [ -f <filename> ]; then echo 0; else echo 1; fi"
> >
> >
> > > -----Original Message-----
> > > From: IBM AIX Discussion List
> > [mailto:aix-l@Princeton.EDU]On Behalf Of
> > > Green, Simon
> > > Sent: Monday, July 22, 2002 9:13 AM
> > > To: aix-l@Princeton.EDU
> > > Subject: Scripting: Check existence of file on remote system
> > >
> > >
> > > I'm writing a Korn Shell script and want to check whether a
> > specific file
> > > exists on a remote server. i.e. rsh remote_server some-command
> > >
> > > Is there a neater way of doing this than ls and grep? (I don't
> > > want to have
> > > a script running on the remote server.)



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