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 <email@example.com>
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"
echo "dir $dir does not exits on $remote"
Reply from: Anchi firstname.lastname@example.org
if rsh $remote ls -d $directory 2>/dev/null | egrep -s $directory
echo $directory exists
echo $directory not found
Reply from : Phil Barone email@example.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
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
the directory name and looks at script 1's output. If 1 then dir or file
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.
=========== ==== === ======= Vassilo Walluschnig ==
========= === ==== === === ====== Planning Information ==
======== ========= === ============ Urban Developement ==
======= == === ===== ========== Greater Johannesburg ==
====== ==== === ======== ========= Metropolitan Council ==
====== === === === === ========== 27 11 407-6125 ==
======= == === ============ firstname.lastname@example.org ==
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:01 CDT