2
1
I want to use netcat to dump a number of blocks of strings to a file. I've been running this in my linux terminal and everything works very well until I try to detach my command line. If I run my command as a detached session netcat stops after the first round of strings.
In short, this works:
nc localhost 3000 > test.txt
But this doesn't:
nc localhost 3000 > test.txt &
[1] 9040
max@starbuck ncats]$
[1]+ Stopped nc localhost 3000 > test.txt
I suppose this has to do with reaching the end of a send on the server side, but I don't know enough about netcat to tell it, "hey! stay awake until your connection drops"
Ideas? Thanks!!!
My guess is that
nc
is trying to read from its controlling terminal and is gettingSIGTTIN
and stopping. Does it work if you add</dev/null
to thenc
command line to tell it to not try to read from standard input? – rra – 2013-03-21T19:53:13.293Or if you run nc from a screen session? – tink – 2013-03-21T19:54:18.477
adding
< /dev/null
just causes it to exit immediately. Screen is a possibility, but doesn't explain why this happens. I'll use screen if I can't figure it out. – None – 2013-03-21T20:39:48.620