Why is this script not working?

for file in $(find /home/p611568/*.rpt -mtime -2 | grep -v ftplog)
 do
   awk '$1 == "XifPages," {PAGE = $5}
        $1 == "XifEndOfDocuments," {LINE = $5}
        index($0,"Value") && index($1,"Info") {sevGTI = 1}
        END {if (sevGTI)
                printf "%7s%10s%s",PAGE,LINE
        }
       ' $file>>/home/p611568/new.txt
       chmod 775 /home/p611568/new.txt
done

Wouldn't it be nice if you told us WHAT is not working, for WHAT input data?

Given that you haven't shown us what input this script is processing, what output you are hoping to produce, what diagnostic messages are being produced when you run this script, told us what shell you're using, nor told us what operating system you're using, it is hard to guess at what might be wrong other than to note that the format string in the printf call in your awk code tries to print three strings but is only given two variables to be printed by that format string. And, of course, all of your printed page and line numbers will be on a single partial line since no <newline> character will be printed by anything in your script.

sorry the file in am inputting is anything that ends with .rpt

home/p611568/d2e/logs/*.rpt

I have to pull these four lines out from the file:

 Info    ApplicationParmValues(Job)      Application Parameters...Name = gpad135

and gpad135 (print $6) and name it job name[/COLOR]

 Total XifPages                              1                     1                     1                     1 

From the last field 1 (print $6) and name it pages[/COLOR]

Total XifEndOfDocuments             1                  1             1                    1      

from the last field 1(print $6) and name it as lines

Info    GenericInfo(Job)        CompletionCode: Value=0, Description=The task has completed successfully without errors

the code I have to revise is:

 [for file in $(find /home/p611568/d2e/logs/*.rpt -mtime -2 | grep -v ftplog)
 do
 
 awk '$1 == "Monday," {DATE = $2 $3 $4}
        $1 == "Monday," {TIME = $6}
        $1 == "Tuesday," {DATE = $2 $3 $4}
        $1 == "Tuesday," {TIME = $6}
        $1 == "Wednesday," {DATE = $2 $3 $4}
        $1 == "Wednesday," {TIME = $6}
        $1 == "Thursday," {DATE = $2 $3 $4}
        $1 == "Thursday," {TIME = $6}
        $1 == "Friday," {DATE = $2 $3 $4}
        $1 == "Friday," {TIME = $6}
        $1 == "Saturday," {DATE = $2 $3 $4}
        $1 == "Saturday," {TIME = $6}
        $1 == "Sunday," {DATE = $2 $3 $4}
        $1 == "Sunday," {TIME = $6}
        $1 == "Info" {QName = $6}
#       $1 == "Info" {Value = $4}
        $1 == "XifPages" {pages = $6}
        $1 == "Value" {Value = $4}
        index($0,"Value") && index($1,"Info") {sevGTI = 1}
        END {if (sevGTI)
                printf "%20s%10s%10s%20s%10s%10s%s",DATE,TIME,QName,pages,Value,ORS
        }
       ' $file>>/home/p611568/xenoshistory.txt
       chmod 775 /home/p611568/xenoshistory.txt
done]

I have revised it several times but NOTHING I do seems to work. Please advise. thanks. I am a beginner at writing scripts and any input you could give me I would appreciate it.

Your specification is very difficult to understand; I give up. Some comments:

  • None of the sample input lines you posted has a weekday.
  • None of the $1 has any of the Xif... values.
  • Is PAGE in post#1 the same as pages in post#4?
  • Is "job name" the same as QNAME ?
  • still yout printf format string has one more format specifier than variables to print.