
Examples for using socat - shawndumas
http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
======
namecast
I love socat one-liners. Here's a quick one that I've been using to image new
machines (data volumes only; I prefer puppet/chef/ansible for installing my OS
and configuring programs):

On the receiver, let's listen on an SSL socket and output the stream of data
we receive to dd for writing to a partition:

socat openssl-listen:9999 | dd of=/dev/sdc1

Now on the sender, all we have to do is

dd if=/dev/sdb1 | socat - openssl:receivinghost:9999

And bam, /dev/sdb1 on the sender is imaged to /dev/sdc1 on the receiving host.
Note that dd only knows to read what socat feeds it, so make sure nothing else
is connecting to that socket or you'll get a weird image that fsck probably
won't be able to save.

~~~
sn
Depending on your available bandwidth, cpu etc. you may want to compress /
uncompress inline. I just tried this locally:

sudo dd if=/dev/sda2 | bzip2 | pv | bunzip2 | dd of=/tmp/tmp

204800+0 records out 104857600 bytes (105 MB) copied, 23.1976 s, 4.5 MB/s

84.6MB 0:00:27 [3.02MB/s] 204800+0 records in

204800+0 records out 104857600 bytes (105 MB) copied, 28.0081 s, 3.7 MB/s

------
jcutrell
Added this to a gist -
[https://gist.github.com/jcutrell/7165336](https://gist.github.com/jcutrell/7165336)
\- might would be useful if someone could get this to the place where it's
highlighting properly (me or anyone who wants to fork). I'd like to learn from
this, but I don't really know where to start, so I figured taking it to a
public-ish place might help that happen (if this isn't a good practice,
someone please do let me know).

------
slashdotaccount
Submitted link is outdated. Instead, rely on the official repo:
[http://repo.or.cz/w/socat.git/blob/HEAD:/EXAMPLES](http://repo.or.cz/w/socat.git/blob/HEAD:/EXAMPLES)

Homepage: [http://www.dest-
unreach.org/socat/doc/socat.html#EXAMPLES](http://www.dest-
unreach.org/socat/doc/socat.html#EXAMPLES)

