I have some simple gawk programs. I am using cygwin on a windows machine to achieve my task. Setup is that we have a folder that contains error messages in .xml format. I need to pull two values out of each file and dump the results into an output file. I have two gawk programs, 1 to pull the data out, and 1 to build a list to be executed for each file. These scripts (obviously modified) work for another directory of errors, but for this one, I also need the filename passed out.
First file= g_upacct_sim This one pulls the data out. The formatting is correct for retrieving the data and dumping to a file
File 2= g_upacct_bld This one build a list to execute g_upacct_sim for each file in the directory. List is exported to a file to be executed.
File 3= getupacct This one runs everything. It creates the filelist file, uses g_upacct_bld to build the list in "doupacct", and executes doupacct
The problem is that g_upacct_sim doesn't pass the file name, it passes the file contents. When I wrap "" around it, it passes '$0' out. The final file that contains the data I need is called upacct_out. Also, I realize that the path may come with it, path or no path is fine either way. I'm not picky.
Any ideas on this one? These scripts work as they are supposed to, except for getting the filename to output.
Any help would be greatly appreciated
First file= g_upacct_sim This one pulls the data out. The formatting is correct for retrieving the data and dumping to a file
BEGIN {
one = "xxx"
two = "yyy"
}
{
if ($0~/Market/) {
t1 = index($0,"Market>")
t2 = substr($0,t1+7)
t3 = index(t2,"<")
t4 = substr(t2,1,t3-1)
one = t4
}
if ($0~/TrafficId/) {
t1 = index($0,"TrafficId>")
t2 = substr($0,t1+10)
t3 = index(t2,"<")
t4 = substr(t2,1,t3-1)
two = t4
exit
}
}
END {
printf("%s\t%s\t%s\n",one,two,$0)
}
File 2= g_upacct_bld This one build a list to execute g_upacct_sim for each file in the directory. List is exported to a file to be executed.
BEGIN {
basedir = "\"/cygdrive/z/Faults/UpdatedAccounts"
}
{
printf("gawk -f g_upacct_sim %s/%s\" >> upacct_out\n",basedir,$0)
}
File 3= getupacct This one runs everything. It creates the filelist file, uses g_upacct_bld to build the list in "doupacct", and executes doupacct
#!/bin/sh
ls /cygdrive/z/Faults/UpdatedAccounts > filelist2
gawk -f g_upacct_bld filelist2 > doupacct
sleep 2s
chmod 777 doupacct
./doupacct
The problem is that g_upacct_sim doesn't pass the file name, it passes the file contents. When I wrap "" around it, it passes '$0' out. The final file that contains the data I need is called upacct_out. Also, I realize that the path may come with it, path or no path is fine either way. I'm not picky.
Any ideas on this one? These scripts work as they are supposed to, except for getting the filename to output.
Any help would be greatly appreciated