Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to send data (plain text string) to a port at a remote computer using terminal utility. The string would be used to trigger something on the remote computer running a program that would listen to that specific port.

I used netcat command and tried a few combination of the following but can't seem to get the parameter right. Can someone point me out where am I doing wrong?

eddy-2:Desktop eddy$ nc IPADDRESS PORT >  woc.txt
eddy-2:Desktop eddy$ nc IPADDRESS PORT <  woc.txt

P.S: woc.txt contains plain text string of the said command.

Edit: I am trying to send a string from OSX to Windows XP where the specific port is open by default.

share|improve this question
up vote 4 down vote accepted

Use netcat as so:

Server: cat woc.txt | nc -l -p PORT

Client: nc HOST PORT > woc.txt

Thanks to garyjohn for the above modification.

share|improve this answer
Added an edit to my post above. I am trying to send a string from OSX to Windows XP where the specific port is open by default. Must cat and netcat be running at the same time for this thing to work. Note: I tried quite a number of other combination from man page but felt that I was missing something so I asked. – Eddy Dec 23 '10 at 2:57
@Eddy - No. Run the server first (it will appear to hang while waiting for a client), client second. – new123456 Dec 23 '10 at 3:01
nc IPADDRESS PORT < woc.txt should work fine. What do have listening on the server's PORT? – garyjohn Dec 23 '10 at 6:48
@Eddy: Your server command is missing a -p. It should be nc -l -p PORT < woc.txt. Also, I understood new123456 to want to send the contents of woc.txt to the server. – garyjohn Dec 23 '10 at 6:53
@garyjohn - Correct. Quoting Eddy: woc.txt contains plaintext string of the said command – new123456 Dec 23 '10 at 14:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.