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
Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSuUser(Contributed Perl DocPerl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr(3pm)

NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr - Use 4-argument "substr" instead of writing "substr($foo, 2, 6) = $bar". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Conway discourages the use of "substr()" as an lvalue, instead recommending that the 4-argument version of "substr()" be used instead. substr($something, 1, 2) = $newvalue; # not ok substr($something, 1, 2, $newvalue); # ok The four-argument form of "substr()" was introduced in Perl 5.005. This policy does not report violations on code which explicitly specifies an earlier version of Perl (e.g. "use 5.004;"). CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
"substr" in perlfunc (or "perldoc -f substr"). "4th argument to substr" in perl5005delta AUTHOR
Graham TerMarsch <graham@howlingfrog.com> COPYRIGHT
Copyright (c) 2005-2011 Graham TerMarsch. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-07 Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr(3pm)
All times are GMT -4. The time now is 09:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy