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!

Automated awk script not working

Status
Not open for further replies.

richclever

IS-IT--Management
Oct 5, 2000
127
FR
I have an email that come in every day and need to pass it to an awk script. I have a filter that picks up the email, and it should then process the file and output to another one.

The problem I have is that it is just adding it to the end of the awk script I have.

The script looks like this:
#!/usr/bin/awk -f

BEGIN {
OUTPUTFILE="/path_to_ouputfile/currency_rates.dat"
print strftime("%d/%m/%y %H:%M:%S",systime()) > OUTPUTFILE
}
$1 ~ /^(USD|GBP|EUR)$/ {
print $1 " " $(NF-1) >> OUTPUTFILE
}

Does anyone have anyidea what is going wrong.

Thanks

Rich
 
is your /usr/bin/awk is actually linked/is gawk?

"strftime" is not part of stock awk [at least on Solaris].

What OS are you on?

if the "print strftime(...)" fails, all you print's will be APPENDED [not appended to a truncated file].

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Vlad is right. systime() and strftime() are in neither awk nor mawk. Your program requires Gawk.
 
You may try this program:
#!/usr/bin/awk -f
BEGIN {
OUTPUTFILE="/path_to_ouputfile/currency_rates.dat"
"date \"+%d/%m/%Y %T\"" | getline a
print a > OUTPUTFILE
}
$1 ~ /^(USD|GBP|EUR)$/ {
print $1 " " $(NF-1) > OUTPUTFILE
}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top