The "if ( -e filename )" blues...
MUHAMMAD A. MUQUIT
muquit at garfield.ncat.edu
Wed Jun 19 03:38:28 AEST 1991
In article <1991Jun17.195519.12713 at murdoch.acc.Virginia.EDU> Edward Schwab
writes:
>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)
What about this?
-----------------------------------------
#!/bin/csh
setenv OUT for005
setenv PROG asymtc1
if ( -e $OUT.out ) then
echo -n "continue [y]?"
set x=$<
if ( $x != n ) then
echo "Things you want to do here"
endif
else
echo "file does not exist, exiting shell"
endif
------------------------------------------
is this what you want?
Thanks.
- -
:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:
: Muhammad A. Muquit Office: 126 Graham Hall :
: Graduate Student Phone: (919) 334-7737 ext 53 :
: Dept. of Civil Engineering e-mail: muquit at garfield.ncat.edu :
: North Carolina A&T State University or, muquit at vanity.ncat.edu :
: Greensboro, NC 27411 :
:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:
--
More information about the Comp.unix.questions
mailing list