Nick Morrison nickm at internode.com.au
Thu Feb 12 00:41:29 CET 2004

On Thu, 2004-02-12 at 03:18, rat at telecoma.net wrote:
> > 
> > 2) Has anybody seen a way to get information from a GPS device into PD?
> > 
> i use gpsd for the gps and as there is no 
> tcpip object in pd where one can send and
> listen from to the same port i get the data into pd with the following
> shellscript (which i call with giges shell object):
> ----------
> #!/bin/sh
> echo "x;" | nc localhost 2947 > ./data.txt &
> cat ./data.txt | nc localhost 3002 &
> sleep 0.1
> killall -9 nc
> ----------
> the x is an  option i build into gpsd to 
> just send "lat long alt speed".
> i then use a netreceive 3002 in the patch to listen to for the data.

Hi Erich,

At a quick glance, it seems your script would be better written thusly:

echo "x;" | nc localhost 2947 | nc localhost 3002 &
sleep 0.1
killall -9 nc

I think there's no need for the intermediate data.txt.  If you want to
chain commands together, you should use '&&' instead of '&' - '&&' tells
sh to only continue to the next command if the errorlevel of the
previous command is 0.  A single '&' causes the first process to be run
in the background and the second process to run immediately, which could
lead to reading from the file before it is written, which is probably
not what you want.  (ie, if the connect takes a long time for some
reason, there'll be old data in data.txt)

Forgive me if I'm barking up the wrong tree!

The 'killall -9' at the end is a bit evil...

Nick :-)

Nick Morrison <nickm at internode.com.au>
Network Operations Group, Internode

Proud to be the major sponsor of the Adelaide Fringe

More information about the Pd-list mailing list