I have two strings i need to search for in the log file.
The two strings are:
ERROR
com.rolander.promotions.client
awk 'BEGIN {
while((getline < "'${SFILE}'")>0)
S[$0]
FS="\n"; RS="\n"
}
/ERROR/ && /com.rolander.promotions.client/ {
for(X in D) delete D[X];
for(N=2; N<=NF; N++)
{
gsub(/^[ \t]+/, "", $N);
split($N, A, "=");
D[A[1]] = A[2]
i = 3;
while (i in A)
D[A[1]] = D[A[1]] "=" A[i++];
}
printf("%s \n")
}' $DATAFILE
SFILE is suppose to be a file that contains the strings to search for. one string per line. i guess this is redundant since i already hardcoded the strings in the script.
sample log file:
2012-05-30 17:55:58,296 ERROR com.rolander.core.manager.paymentManager.PaymentBL - PaymentBL notifyPaymentOK() method is called. This functionality is not supported.
2012-05-30 17:56:02,855 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception with communication with promotions web service:
2012-05-30 17:56:02,855 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service host: promo.rolandernetworks.net
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service port: 8080
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service path: /promotions/getReferral
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service params: subAccountNumber=101045334
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service http timeout: 10000
2012-05-30 17:56:02,857 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service tcp timeout: 1000
2012-05-30 17:56:02,857 ERROR com.rolander.core.manager.referralManager.ReferralBL - ERROR getting Referral.
basically, i want the script to scan this file and output ONLY lines that contain the two strings i specified.
If you told me what you actually wanted, instead of giving me a program which doesn't do what you want and expecting me to infer what you do want somehow, I could do it.
2012-05-30 17:55:58,296 ERROR com.rolander.core.manager.paymentManager.PaymentBL - PaymentBL notifyPaymentOK() method is called. This functionality is not supported.
2012-05-30 17:56:02,855 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception with communication with promotions web service:
2012-05-30 17:56:02,855 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service host: promo.rolandernetworks.net
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service port: 8080
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service path: /promotions/getReferral
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service params: subAccountNumber=101045334
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service http timeout: 10000
2012-05-30 17:56:02,857 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service tcp timeout: 1000
2012-05-30 17:56:02,857 ERROR com.rolander.core.manager.referralManager.ReferralBL - ERROR getting Referral.
Using the script i pasted above, i want to scan this log file for certain strings which must be on the same line.
The file in which the strings to search for are stored is specified with the $SFILE variable, and the strings appear in the file one string per line. in this particular example, the $SFILE variable may not even be needed since I already hardcoded the strings inside the script itself.
so the script is suppose to read in the DATAFILE, and then print out each line it finds that contains both of the specified strings.