I am listening to a TCP port using netcat, I am receiving a line of comma-deliminated data every 5 minutes and writing it to a text file. Here is the command I'm running:
nc -dl 12.34.56.78 1234 > path/to/my/file & echo $!
When this command is ran via the command line the data is saved to the file and everything is fine.
However, I created a little PHP script that reinstates the netcat listener (using the same command as above) in the event the process stops for whatever reason. The script is executed via a cron job. When this happens, the data is still written to the file however it is always prepended by a string of "^@" characters, the length of which increases each time (every 5 minutes).
Any insight into why this is happening and how to stop it is greatly appreciated!
Matt.