Setting filename on the BEGIN section? 
Author Message
 Setting filename on the BEGIN section?

Hi

I have a script named muto.cgi:

#!/bin/sh
cat QUERY_STRING | gawk -f muto.awk

i find it rather useless...  so how can i determine the file to be
process on the BEGIN section of the awk program and get rid of this
"starter"?

Thanks



Sun, 23 May 1999 03:00:00 GMT  
 Setting filename on the BEGIN section?

Quote:

>Hi

>I have a script named muto.cgi:

>#!/bin/sh
>cat QUERY_STRING | gawk -f muto.awk

>i find it rather useless...  so how can i determine the file to be
>process on the BEGIN section of the awk program and get rid of this
>"starter"?

If QUERY_STRING is the name of a file,
gawk -f muto.awk QUERY_STRING
If it's a variable containing the name of a file:
gawk -f muto.awk $QUERY_STRING
If it's a variable containing the actual text you wish to process:
echo "$QUERY_STRING" | gawk -f muto.awk

--

"You can pay Uncle Sam with the overtime
 Is that all you get for your money?" --Billy Joel



Sun, 23 May 1999 03:00:00 GMT  
 Setting filename on the BEGIN section?

: Hi

: I have a script named muto.cgi:

: #!/bin/sh
: cat QUERY_STRING | gawk -f muto.awk

: i find it rather useless...  so how can i determine the file to be
: process on the BEGIN section of the awk program and get rid of this
: "starter"?

: Thanks

Modify muto.awk - make it executable and include the following lines:

#!/usr/local/bin/gawk -f
BEGIN {
ARGV[1] = "QUERY_STRING"
ARGC = 2
.. # rest of original script

Then,  all you would need to type is:

muto.awk

--
Dan Mercer



Sun, 23 May 1999 03:00:00 GMT  
 Setting filename on the BEGIN section?

Quote:

> I have a script named muto.cgi:

> #!/bin/sh
> cat QUERY_STRING | gawk -f muto.awk

wow.  I would _never_ do that.  I hope QUERY_STRING is strongly
checked before passing it on the command line like that!

Quote:
> i find it rather useless...  so how can i determine the file to be
> process on the BEGIN section of the awk program and get rid of this
> "starter"?

do you need to?

with the same security risks:

#! /bin/sh
gawk -f muto.awk QUERY_STRING

or

#! /bin/sh
gawk -f muto.awk < QUERY_STRING

there may be other, gawk-specific ways that are neater.
--



Thu, 27 May 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. set printer to (<filename>)

2. filename using ASCII cherecter set

3. Value clause in File section and Linkage section

4. How to Specify Variable FileName(!FileName)In Report

5. Using variable filename(!FILENAME)

6. Long Filenames okay for physical filenames???

7. REQUIRES filename (NEEDS filename)

8. DOS 8.3 filenames (how to remove long filenames header)

9. Library os.path.isfile(filename) - long filenames error.

10. Adding PC Filename Extensions to Macintosh Filenames

11. How to program set(X) + set(a) = set(X)

12. How to program set(X) + set(a) = set(X)

 

 
Powered by phpBB® Forum Software