steve fiedler on 11 Aug 2015 06:34:10 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Need Help with a script for netcat

i did try the -d option, not a valid option in netcat v 1.1.  Could only find the -d option on a version for windows.


Date: Tue, 11 Aug 2015 09:21:19 -0400
Subject: Re: [PLUG] Need Help with a script for netcat

Try adding -d option to netcat

On Aug 11, 2015 8:59 AM, "steve fiedler" <> wrote:
I have been having an issue getting a script to work running netcat in the background.  I need to listen on a certain port for info coming from a PBX all day long.  The PBX is sending SMDR data we want to use . ( call length, # of rings, etc....)

I have a script that does nothing but listen on a port for this info and appends a file with this data.  If I run the script in the foreground, it runs all day and gives me exactly what I want.

If I run it in the background or as a daemon from /etc/init.d, it starts but then stops. If I do a ps -ef | grep for the process, the netcat proc is still running but nothing is listening

 I have tried everything I can think of to keep it running, nohup the main script and the netcat command inside the script, ampersands, verbose mode to get a log, nothing will allow this to run in the background. 

Here is the script I am running, its called
INFO=$(hostname | cut -c 4-7)_$(date +%Y%m%d)
/usr/bin/netcat -l -n -p 6000 >> /tmp/smdr_$INFO
Thats it....  If I try to run just the netcat command from the command it will fail also.  The -d option is not valid on netcat V1.1.  There is a -w option that will set  timeout for connects and final net reads.  I thought about setting this to 82800 ( 23 hours) and see if that works.  I do need to kill this job overnight so I can tar up the file and move it. then could restart with a cron job.

Any thoughts?  Is there another way I can accomplish this strictly via the command line ?

Thanks very much for your thoughts,

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --

___________________________________________________________________________ Philadelphia Linux Users Group -- Announcements - General Discussion --
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --