SUMMARY: Checking for directory on remote machine.

From: Vassilo Walluschnig (vassilo@mj.org.za)
Date: Fri Aug 22 1997 - 04:53:24 CDT


Hi All,

Original question.

I would like to check if a directory exists on a remote machine,
from within a script. Therefore, I need the status of this check.
Does anybody have an idea of how to go about this. I don't want to
have to go and create a script on the remote machine.

Reply from: Brion Leary <brion@dia.state.ma.us>

  Assuming you can rsh remote and your shell is /bin/sh, use

  dis=`rsh remote if [ -d $dir ] \; then echo yes \; else echo no \; fi`
  if [ "$dis" = yes ] ; then
  echo "dir $dir exits on $remote"
  else
  echo "dir $dir does not exits on $remote"
  fi

Reply from: Anchi azhang@ect.enron.com

  if rsh $remote ls -d $directory 2>/dev/null | egrep -s $directory
  then
  echo $directory exists
  else
  echo $directory not found
  fi

Reply from : Phil Barone pbarone@harris.com

  I have my admin scripts automounted so I can see that directory on all my
  machines. This way even though you are querying a script that runs on
another
  machine, you don't have to copy it there.

  Example: You have 2 scripts.
    script 1: Meant to run locally, it basically does a if -d directory
or -f file
  then return 1 or yes whatever.( this is just psuedo code ).
    script 2: This script runs from any machine and does a rsh to script 1
with
  the directory name and looks at script 1's output. If 1 then dir or file
  exists.

Thanks guys for all your help.

If anybody is interested in the script I am writing, it transfers software
from a central
server to a list of workstations let me know and I will e-mail it to them.

Regards,
  Vassilo Walluschnig

===============================================================
=========== ==== === ======= Vassilo Walluschnig ==
========= === ==== === === ====== Planning Information ==
======== ========= === ============ Urban Developement ==
======= == === ===== ========== Greater Johannesburg ==
====== ==== === ======== ========= Metropolitan Council ==
====== === === === === ========== 27 11 407-6125 ==
======= == === ============ vassilo@mj.org.za ==
===============================================================



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:01 CDT