hi experts,

i'm new on scripting on sun solaris 8 sparc, need some advices. i have some data in a file like :

20061221 163826.485 20061221 163925.144 058.659 6123456789012 00000E8A 047 08 002 465 00010022 510105642138069
20061221 163915.163 20061221 163925.336 010.173 6123456789012 00000F4F 037 02 002 999 00010022 510103242202784
20061221 163852.363 20061221 163925.549 033.186 6123456789012 00000EED 040 06 002 999 00010022 510105832049518
20061221 163803.035 20061221 163925.708 082.673 6123456789012 00000E26 010 08 002 800 00010022 510105732551708
20061221 163921.293 20061221 163925.787 004.494 6123456789012 00000F6C 039 02 002 999 00008001 510105642169788
20061221 163650.185 20061221 163926.027 155.842 6123456789012 00000D16 051 08 002 465 00008001 510105732672986
20061221 163923.325 20061221 163926.381 003.056 6123456789012 00000F75 062 02 002 123 00008001 510103342614669

example of the data :

20061221 163923.325 20061221 163926.381 003.056 6123456789012 00000F75 062 02 002 123 00008001 510103342614669

underline is shortcode and bold is causes code

the filename is in date format like "2006122001.TDR" and the file generated each hour like 2006122002.TDR,2006122003.TDR,etc. the file log found at /log/TDR/

--> i want to check into the file (e.g. 2006122000.TDR) line by line and get how much shortcode having causes code "00008001".

--> generate it into a file (e.g. 2006122000.log) per hour the info which shortcode having cause code "00008001"

--> count per shortcode how much each short code having causes code "00008001". (e.g. 123 count 20, 465 count 30,etc)

--> send it through sms using syntax : msggen msggen_SMClient.txt 1 "[01234356789]" "[Result of counted data]"

--> the script will running in background and check for the previous hour log file


please advices help to build simple script for this case

Thank you so much


Regards,

bucci

This will generate a report like you asked for.

nawk '
     {	shortcode[$11]=$11	
        causecode[$12]=$12	
        result[$11 $12]++
     }
	END{ for( short in shortcode)
	  {
		for(cause in causecode)
		{
			if(result[short cause])
			{
				print short, "count", cause, result[short cause]
			}
		}

	  }
	} ' filename

You will have to write another small script that runs under cron (once every hour) and calls the above nawk code with the correct file name.
awk on Solaris is crippled, you have to use nawk to get the features above.

I don't know sms, so someone else will have to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.