Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!uvaarpa!murdoch!turing!eas From: eas@turing.acs.virginia.edu (Edward A. Schwab) Newsgroups: comp.unix.questions Subject: The "if ( -e filename )" blues... Message-ID: <1991Jun17.195519.12713@murdoch.acc.Virginia.EDU> Date: 17 Jun 91 19:55:19 GMT Sender: usenet@murdoch.acc.Virginia.EDU Organization: University of Virginia Lines: 41 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@turing.acs.virginia.edu) (eschwab@polaris.cv.nrao.edu)