Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with multiple ARGV

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I have the following script

BEGIN {
print " "
}
.... lots of functions here

{
#bypass In fact there is no input file
}

END {

lots of calls to the above functions here
}

I run the script like this:
nawk -f script.awk var1 var2

Within the script I get var1 and var2 from ARGV[1] and ARGV[2] without any problems.

I then get an error nawk: can't open file var2, why ?
The script runs fine if I put all the statements frm END{ } into BEGIN { } but I still get the error at the end.


 
Do all your stuff in the BEGIN section and terminate them with an exit statement. Remove all other sections.
You may also decrement ARGC each time you pick an ARGV element.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top