home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!navarra
- From: navarra@casbah.acns.nwu.edu (John Navarra)
- Subject: Passing control to user in nawk script
- Message-ID: <1992Aug29.062511.2486@news.acns.nwu.edu>
- Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
- Organization: Northwestern University, Evanston Illinois.
- Date: Sat, 29 Aug 1992 06:25:11 GMT
- Lines: 46
-
-
- I have the following lines in a nawk script:
- BEGIN {
- if ( !system("test -r outline")) {
- printf "outline exists. Overwrite? "
- getline <"-"
- response=$0
- print response
- }
- }
-
- $0 ~ /^[Nn]|NO|no|No|$/ {exit}
-
- FNR==1,FNR==2 {
- print FILENAME, $0 >"outline"
- }' $*
-
-
- I look in the BEGIN script if the file 'outline' exists and if
- it does I want to ask the user if he wants to overwrite the file. The
- problem is that I pass all the shell args to the script when I invoke
- it. I would like to regain control of the execution of the script if
- the file outline exists (i.e. response y or n to overwriting) THEN
- pass all the shell args to nawk. Is there an easy way to do this?
- Have I made myself clear?
-
- it should do something like
- $ program file1 file2 .. fileN
- outline exists. Overwrite? y
-
- put put ... results.
-
- or
- $ program file1 file2 .. fileN
- put put ... results.
-
- I *need* to do the test from within the nawk script -- not from within
- the shell script.
-
- -tms
-
- --
- You can get further with a kind word | You can get further with a kind word
- and a gun than a kind word alone. | and a phaser than a kind word and a gun.
- --al capone | -- John Navarra
- =======From the Lab of the MaD ScIenTIst....navarra@casbah.acns.nwu.edu========
-