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 would like to pipe data from one machine in the command line to another machine over tcp. I guess I could write a socket server but this must already be implemented. For example I could use it to xz a file and send it over the network to the other side over a specified port, where I could decode and save it:

machine A: strarc -c -d:c:/windows | xz -c -z - | magicsend -p 80 -h machine B: magicreceive -p 80 | xz -d -f - | strarc -x -d:x:/windows

I would like to do this in Linux and/or Windows with open-source tools. So Linux tools that have a[n unofficial] Windows port are preferable. :)

A working example command line is much appreciated.

(Note that on a Linux example I would do cat /vmlinuz instead of strarc, sure it's not quite equivalent. ;) )

share|improve this question
up vote 3 down vote accepted

Use netcat. See the "CLIENT/SERVER" section of "man netcat". One machine B:

nc -l 1234 | xz -c > sammy.xz

and on machine A:

cat sammy | nc 1234

Note that there can be security implications to leaving ports open in this manner.

As mpy points out, it is more efficient in terms of network bandwidth to compress on the sending side:

xz -c sammy | nc 1234

And just save on the receiving side:

nc -l 1234 > sammy.xz
share|improve this answer
works quite well, however for some reason this just won't exit for me after sammy is fully read. I think it's netcat. Can it be the implementation I use causing the problem, or is this netcat's design, thus expected? Can I make it somehow exit once sammy is read (EOF), (to arbitrary file sizes and reading times)? – n611x007 Apr 20 '13 at 6:23
@naxa: Hmm.. not clear why this should be. I don't have Windows handy but all of the documentation seems to say that also on Windows the server (B) should exit after the client (A) finishes writing to the pipe. can you post your commands? Sure you are using -l and not -L? – Jonathan Ben-Avraham Apr 21 '13 at 18:35
I'm puzzled, why you use xz on receiver's side?! It would be much more efficient, if you compress on sender (machine A): xz -c sammy | nc 1234 and inflate on receiver (machine B): nc -l 1234 | xzcat > sammy and IMHO the intention of OP. – mpy May 5 '13 at 11:56
@mpy: I appended your comment to my answer, thanks. – Jonathan Ben-Avraham May 5 '13 at 12:08
I appreciate that, already upvoted. – mpy May 5 '13 at 12:10

Netcat should suit your needs; I don't have the documentation handy so can't be certain, but I think the sending side's command would be [...] | nc -h192.168.1.100 -p80, while the receiving side would use nc -l -p80 | [...].

share|improve this answer

Since you need to remote log in to at least one of the machines (to run either magicsend or magicreceive) could you just use ssh?

ssh clients are easy to come by on Windows (just install cygwin, for example.) ssh servers are also easy to come by, but may be harder to install/configure.

something like this if you are currently on the console of machine A and machine B is remote:

machine A: strarc whatever | xz -c -z - | ssh me@machineB '(xz -d -f - | strarc somethingelse)'

or if you are on the console of machine B and need to remote login to machine A then:

machine B: ssh me@machineA '(strarc whatever | xz -c -z -)' | xz -d -f - | strarc somethingelse

share|improve this answer
but may be harder to install/configure out of curiosity did you do this? I did with cygwin and it felt kind of limited and cumbersome. – n611x007 Mar 8 at 11:49

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.