#!/bin/csh -f
#
# valid_paths 
#
# for input path list, return list which is valid (paths which exist)
# Calling Sequence:
# set valid_paths=`valid_paths "path1,path2,path3,...pathn"
#
if ($#argv != 1) then				# need one parameter
   echo " " 
   exit
endif

set arg="$1"
# assume comma or blank delimited search string
set outarr =(`echo $arg | sed s+","+" "+g`)	# replace comma with blank

set outlist=""					# initialize output

foreach elem ($outarr) 
   if (-d $elem) then 				# existing directory?
      set outlist=($outlist $elem)		# yes, so add to output list
   endif
end

echo "$outlist[1]"				 	# return valid list
exit
