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.

link|improve this question
feedback

1 Answer

up vote 2 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.

link|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
1  
@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
feedback

Your Answer

 
or
required, but never shown

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