Hi,
I am running this command through a shell script and getting the error mentioned in the subject line:
testing.awk -f x.txt TNAME
My testing.awk file contains something like
++++++++++++++++++
#!/usr/bin/awk -f
BEGIN{
TAB_NAME="INSERT_ONE_" ARGV[ARGC-1] ;
}
if ( $1=="JAM_ONE" && $2=="Starting" ) {
print "insert into " TAB_NAME " (table_name) values('" $6 "');"
print "\n";
}
if ( $1=="JAM_TWO" && $2=="Finishing" ) {
print "insert into " TAB_NAME " (table_name) values('" $6 "');"
print "\n";
}
....some other piece of code..
++++++++++++++++++
When i am trying to run this code:
testing.awk -f x.txt TNAME
It gives me a error (which i think is because of the fact it is trying to see TNAME as a file).
awk: testing.awk:32: (FILENAME=./X/X//x.txt FNR=4) fatal: cannot open file `TNAME' for reading (No such file or directory)
Can anyone suggest how to resolve the error? How to modify my code such that the last parameter in the command given above doesn't take it as a file name. I think it is trying to resolve the last parameter as a file and throwing this error.
I call the above command through a different shell script's for loop
for file_name in $xdir/*.done
do
if [[ -f $file_name ]]
then
testing.awk -f x.txt TNAME >> $command_file
fi
done