awk for streaming data - if/then


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk for streaming data - if/then
# 1  
Old 09-28-2017
awk for streaming data - if/then

Hello,

I've written an awk one-liner to parse a stream of real-time data. I invoke a program that gives me output from which I extract a few columns, perform some simple calculations, and then stream that data into a portal using an http string. It's tricky because I have to run it every second to parse the data I need, but it works.

My question is about adding in an if/then statement. I need to check if the output of Ntripclient2.py actually has the data I need. If it doesn't I need to move on, not parse it, and run the awk one-liner again until I actually get the data I need. The problem is I end up parsing an error message, and it bogs down my portal.

I need to check NR==13, if($5==0) skip the parse step and keep going. Does that make sense?

Here's the one-liner:

Code:
Ntripclient2.py --user $1 $2.unavco.org $3 $4_RTX | awk -F, 'NR>7 {cmd="curl \42http://'$5'.chordsrt.com/measurements/url_create?instrument_id='$6'&lat="substr($5,1,2)+(substr($5,3)/60)"&lon="substr($7,1,3)+(substr($7,4)/60)"&height="substr($12,4)"&at=""20"substr($4,5,2)"-"substr($4,1,2)"-"substr($4,3,2)"T"substr($3,1,2)":"substr($3,3,2)":"substr($3,5,2)"\42";system(cmd)}'



Moderator's Comments:
Mod Comment Please use CODE tags correctly as required by forum rules!

Last edited by RudiC; 09-28-2017 at 04:00 PM.. Reason: Changed ICODE to CODE tags.
# 2  
Old 09-28-2017
You can use a next statement:-
Code:
NR > 7 { 
	if ( ( NR == 13) || ( $5 == 0 ) )
		next
	else
		<parsing code here>
}

These 2 Users Gave Thanks to Yoda For This Post:
# 3  
Old 09-28-2017
Smilie Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute awk output with continuous streaming input

I need to parse some continuous output from a program (i.e. aScript.py) into a portal that uses curl. I've written a simple awk one-liner to parse the information that is output from aScript.py, but I'm not able to execute it. I can succeed with just one line of the output from aScript.py: echo... (2 Replies)
Discussion started by: jm4smtddd
2 Replies

2. Shell Programming and Scripting

awk --> math-operation in data-record and joining with second file data

Hi! I have a pretty complex job - at least for me! i have two csv-files with meassurement-data: fileA ...... (2 Replies)
Discussion started by: IMPe
2 Replies

3. Shell Programming and Scripting

Help with parsing data with awk , eliminating unwanted data

Experts , Below is the data: --- Physical volumes --- PV Name /dev/dsk/c1t2d0 VG Name /dev/vg00 PV Status available Allocatable yes VGDA 2 Cur LV 8 PE Size (Mbytes) 8 Total PE 4350 Free PE 2036 Allocated PE 2314 Stale PE 0 IO Timeout (Seconds) default --- Physical volumes ---... (5 Replies)
Discussion started by: rveri
5 Replies

4. Shell Programming and Scripting

save streaming video data for later viewing?

I have limited bandwidth in my apartment and no cable TV service. I was wondering if it is possible to write a script that would download the video data from my favorite TV shows (legally... many networks post their videos online for free) while I sleep, so that later I can watch them on my TV... (5 Replies)
Discussion started by: euclid3628800
5 Replies
Login or Register to Ask a Question