Sponsored Content
Top Forums Shell Programming and Scripting awk for streaming data - if/then Post 303004260 by jm4smtddd on Thursday 28th of September 2017 02:58:12 PM
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.
 

4 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgawk | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for gawk is available on http://opensolaris.org. Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 09:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy