Return to BSD News archive
Xref: sserve comp.unix.shell:20398 comp.unix.bsd:16045 Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!newshost.marcam.com!news.mathworks.com!panix!acinader.dialup.access.net!user From: acinader@panix.com (Arthur Cinader) Newsgroups: comp.unix.shell,comp.unix.question,comp.unix.bsd Subject: csh script - unexpected results? (BSDI) Followup-To: comp.unix.shell Date: Sat, 04 Feb 1995 12:36:19 -0500 Organization: Working on it Lines: 67 Distribution: world Message-ID: <acinader-0402951236190001@acinader.dialup.access.net> Reply-To: acinader@panix.com NNTP-Posting-Host: 198.7.7.80 Keywords: BSDI csh X-Newsreader: Value-Added NewsWatcher 2.0b22.0+ Below is a simple script to illustrate simple error handeling. Problem is, I'm not getting the expected results. Why? (I'm running BSDI 1.1, I don't know if there is a way to qualify my version of csh) The example comes from the "Unix C shell guide," Anderson & Anderson, p.42. The script is called ~/bin/ppd with the execute permission set. Numbered lines for clarity. 1 # csh to prepend standard input to file argument 2 # Version 2 3 4 if ($#argv !=1) then # check for number of args 5 echo "Usage: ppd output_file" 6 exit 1 # exit on error 7 endif 8 9 set tf = /tmp/ppd.$$ # name temp file 10 set dest = $argv[1] # get argument name 11 12 if (-w $dest) then # make sure it's writeable 13 cat - $dest > $tf # concatenate tf with target 14 mv $tf $dest # replace original file 15 exit 0 # exit with good status 16 endif 17 18 if (-e $dest) then # does it exist 19 echo "ppd: $dest not writable. " 20 else 21 echo "ppd: $dest does not exist." 22 endif 23 exit 1 # exit on error Below is input with resulting output versus expected output. %(date; du ~) | ppd if: Expression Syntax. Vs. %(date; du ~) | ppd Usage: ppd output_file %ppd memo < header if: expression syntax Vs. %ppd memo < header ppd: memo does not exist %ppd /etc/passwd < header if: expression syntax Vs. %ppd /etc/passwd < header ppd: /etc/password not writeable. Any ideas? [followup set to comp.unix.shells] Arthur acinader@panix.com