[comp.unix.wizards] cd problem

anamaria%saffron.wpd@sgi.com (Ana Maria De Alvare') (08/09/90)

In csh you can test in an if statement if the directory exist and 
then do the cd.

For example:

if (-d directoryname) then
echo it exist
else
echo it does not exist
endif

Ana Maria
-------------------------------------------------------------------------------
Ana Maria De Alvare' 	MTS Secure IRIX            	 Silicon Graphics, Inc.
anamaria@sgi.COM    {decwrl,sun}!sgi!whizzer!saffron!anamaria      415-335-1549

-------------------------------------------------------------------------------

anamaria%saffron.wpd@sgi.com (Ana Maria De Alvare') (08/09/90)

To answer your mail:
	Date: Wed, 8 Aug 90 12:14:46 EDT
	From: "Ian! D. Allen [CGL]" <idallen@watcgl.waterloo.edu>
	Message-Id: <9008081614.AA11112@watcgl.waterloo.edu>
	To: anamaria%saffron.wpd@sgi.com
	Subject: Re: cd problem
	
	And how do you know that you have *permission* to cd into the directory?
	Knowing that it is a directory isn't enough.
	
	


---
To know if you have access use the expression flags in the CSH manual
pages.

For example to know if you have read access and the directory exist do:

if (-d directoryname) then
        if (-r directoryname) then 
                ls directoryname
        else
        echo no read access
else 
echo directory does not exist
endif


I hope this helps. 

Ana Maria
-------------------------------------------------------------------------------
Ana Maria De Alvare' 	MTS Secure IRIX            	 Silicon Graphics, Inc.
anamaria@sgi.COM    {decwrl,sun}!sgi!whizzer!saffron!anamaria      415-335-1549

-------------------------------------------------------------------------------

anamaria%saffron.wpd@sgi.com (Ana Maria De Alvare') (08/09/90)

Of course my example won't work.  You have to use the -x flag to
assert that one has execute permission on the directory.

I just gave an example of flag usage.

-------------------------------------------------------------------------------
Ana Maria De Alvare' 	MTS Secure IRIX            	 Silicon Graphics, Inc.
anamaria@sgi.COM    {decwrl,sun}!sgi!whizzer!saffron!anamaria      415-335-1549

-------------------------------------------------------------------------------