2

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.

1 Answer 1

4

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.

5
  • 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.
    – Scott
    Dec 23, 2010 at 2:57
  • @Eddy - No. Run the server first (it will appear to hang while waiting for a client), client second.
    – new123456
    Dec 23, 2010 at 3:01
  • nc IPADDRESS PORT < woc.txt should work fine. What do have listening on the server's PORT?
    – garyjohn
    Dec 23, 2010 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, 2010 at 6:53
  • @garyjohn - Correct. Quoting Eddy: woc.txt contains plaintext string of the said command
    – new123456
    Dec 23, 2010 at 14:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .