The "if ( -e filename )" blues...
Edward A. Schwab
eas at turing.acs.virginia.edu
Tue Jun 18 05:55:19 AEST 1991
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... :)
I hope this message makes SOME sense when you look at the actual shell script
below:
-----------------------------------------------------------------------------
#!/bin/csh
setenv OUT for005
setenv PROG asymtc1
if ( -e $OUT.out ) clear
if ( -e $OUT.out ) echo '******************************************************'
if ( -e $OUT.out ) echo 'You have a leftover '$OUT'.out file. Since '$PROG''
if ( -e $OUT.out ) echo 'will end up choking on this leftover file, I am going'
if ( -e $OUT.out ) echo 'to delete it for you. If you do not want me to'
if ( -e $OUT.out ) echo 'delete it, hit ^C, ENTER, and rename it to a different'
if ( -e $OUT.out ) echo ' filename.'
if ( -e $OUT.out ) echo '******************************************************'
if ( -e $OUT.out ) echo ' '
if ( -e $OUT.out ) echo ' If you want it deleted, press ENTER now to continue.'
if ( -e $OUT.out ) set x=$<
if ( -e $OUT.out ) rm $OUT.out
.$PROG
echo 'Now filtering...'
mv $OUT.out $OUT.asa
asa $OUT.asa >$OUT.out
rm $OUT.asa
echo ' '
echo 'Done! File written to '$OUT.out'.'
echo ' '
-------------------------------------------------------------------------------
Thanks,
- Ed (eas at turing.acs.virginia.edu)
(eschwab at polaris.cv.nrao.edu)
More information about the Comp.unix.questions
mailing list