The "if ( -e filename )" blues...
Tom Christiansen
tchrist at convex.COM
Tue Jun 18 09:12:51 AEST 1991
>From the keyboard of eas at turing.acs.virginia.edu (Edward A. Schwab):
:Help! I'm trying to run a simple csh shell file that sets $OUT.out to an
:output filename and $PROG to a program name, will search for $OUT.out, and
:delete it... I'm trying to do an "if ( -e $OUT.out ) set x=$<", which will
:wait for an ENTER before continuing with the program... The only thing is
:that the "if ( -e )" statement (that searches for the existance of the file)
:runs if there is an actual $OUT.out file or not... **sigh** How can I make
:this wait for an enter keypress ONLY if $OUT.out exists??? All of the other
:if -e's work (the echos and the rm...) BTW, the actual executable is called
:.$PROG; this is called up by $PROG... :)
you need to say
if (-e foo) then
set x = "$<"
endif
so it doesn't try to eval the $< even when it doesn't need to.
:
:I hope this message makes SOME sense when you look at the actual shell script
:below:
:-----------------------------------------------------------------------------
:#!/bin/csh
you forgot the -f.
:setenv OUT for005
:setenv PROG asymtc1
now you have a WHOLE LOT of -e's. why don't you just do one and make
a block and save a lot of stat's, plus the $< headache?
there's nothing in this script demanding csh. why don't you do yourself
a favor and use sh? it sure beats a boot to the head, which is all
csh will ever give you.
--tom
--
Tom Christiansen tchrist at convex.com convex!tchrist
"So much mail, so little time."
More information about the Comp.unix.questions
mailing list