Friday, January 10, 2014

ubuntu 10 & 14 & piping data to netcat

So, I decided to update a nice old system that does temperature graphing for us.
The first issue was the lack of various pms that the perl scripts required.
Once that was tackled, I found that the local device graph function was working.  But, my netcat grabs were not .  
So, yes, I could echo and printf my life away and get my values, but in a script, this:

my $values = `echo "GET /temp HTTP/1.0\n\n" |nc my.temp.sys 80 `;

Did not work.  Not at all.

So, I thought and thought and did a little digging, and sure enough there’s a registered bug with nc when one wants to pipe data to it.  
To get those values, here’s what the line’s to look like:

my $values = `echo "GET /temp HTTP/1.0\n\n" |nc my.temp.sys 80 -q -1`;

So, if you’re using newish ubuntus, 10+, now you know.
Post a Comment