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 curl "awk output" | xargs curl
, but this doesn't work for continuous output from the aScript.py
program. Here is what I want to be able to do:
aScript.py --user aUser:userPswd server.org PORT CODE | awk -F, 'NR>6 {print "curl \42http://aServerSomewhere.com/measurements/url_create?instrument_id=1&VAR1="substr($5,1,2)substr($5,5)"&VAR2="substr($7,1,3)"&VAR3="substr($12,4)"\42"}' | execute awk output (what to do here?)
In this example aScript.py
is extracting data that is continuously collected. My awk
line is parsing the output into a line necessary for porting the data into a program. How can I get the output of my awk
line to execute continuously as the data comes in? Perhaps a loop is necessary?
Solved with:
aScript.py --user aUser:userPswd server.org PORT CODE | awk -F, 'NR>6 {cmd="curl \42http://aServerSomewhere.com/measurements/url_create?instrument_id=1&VAR1="substr($5,1,2)substr($5,5)"&VAR2="substr($7,1,3)"&VAR3="substr($12,4)"\42";system(cmd)}'