home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10503 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.7 KB  |  57 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!navarra
  3. From: navarra@casbah.acns.nwu.edu (John Navarra)
  4. Subject: Passing control to user in nawk script
  5. Message-ID: <1992Aug29.062511.2486@news.acns.nwu.edu>
  6. Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
  7. Organization: Northwestern University, Evanston Illinois.
  8. Date: Sat, 29 Aug 1992 06:25:11 GMT
  9. Lines: 46
  10.  
  11.  
  12. I have the following lines in a nawk script:
  13. BEGIN {
  14. if ( !system("test -r outline")) {
  15.           printf "outline exists. Overwrite? "
  16.           getline <"-"
  17.           response=$0
  18.           print response
  19.        }
  20. }
  21.  
  22. $0 ~ /^[Nn]|NO|no|No|$/ {exit}
  23.  
  24. FNR==1,FNR==2 {
  25.       print FILENAME, $0 >"outline"
  26. }' $* 
  27.  
  28.  
  29.     I look in the BEGIN script if the file 'outline' exists and if
  30. it does I want to ask the user if he wants to overwrite the file. The
  31. problem is that I pass all the shell args to the script when I invoke
  32. it. I would like to regain control of the execution of the script if
  33. the file outline exists (i.e. response y or n to overwriting) THEN 
  34. pass all the shell args to nawk. Is there an easy way to do this? 
  35. Have I made myself clear?
  36.  
  37. it should do something like
  38. $ program file1 file2 .. fileN
  39. outline exists. Overwrite? y
  40.  
  41. put put ... results. 
  42.  
  43. or
  44. $ program file1 file2 .. fileN
  45. put put ... results.
  46.  
  47. I *need* to do the test from within the nawk script -- not from within
  48. the shell script.
  49.  
  50. -tms
  51.  
  52. -- 
  53. You can get further with a kind word | You can get further with a kind word
  54. and a gun than a kind word alone.    | and a phaser than a kind word and a gun.
  55.           --al capone                |           -- John Navarra
  56. =======From the Lab of the MaD ScIenTIst....navarra@casbah.acns.nwu.edu========
  57.