<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>robert's rant room &#187; voodoo</title>
	<atom:link href="http://rrr.thetruth.de/category/voodoo/feed/" rel="self" type="application/rss+xml" />
	<link>http://rrr.thetruth.de</link>
	<description>emerge --update world</description>
	<lastBuildDate>Wed, 23 Jun 2010 13:02:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Remote copy without scp</title>
		<link>http://rrr.thetruth.de/2009/04/remote-copy-without-scp/</link>
		<comments>http://rrr.thetruth.de/2009/04/remote-copy-without-scp/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 15:43:54 +0000</pubDate>
		<dc:creator>rbu</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[voodoo]]></category>

		<guid isPermaLink="false">http://rrr.thetruth.de/?p=25</guid>
		<description><![CDATA[I often need to copy small files (configs, scripts, patches) from one machine to another and I have found using &#8220;cat&#8221; and copy-paste to be very unreliable for this: You lose tab characters, file names, permissions, and it cannot handle binaries. Plus, it gets tedious for long text files. So I added a function to [...]]]></description>
			<content:encoded><![CDATA[<p>I often need to copy small files (configs, scripts, patches) from one machine to another and I have found using &#8220;cat&#8221; and copy-paste to be very unreliable for this: You lose tab characters, file names, permissions, and it cannot handle binaries. Plus, it gets tedious for long text files. So I added a function to my .zshrc that takes file names as an argument and prints shell code you can simply copy and paste into a remote ssh session. The current working directory will then contain the files:</p>
<pre>rbu@localhost ~/copy-example $ ls -l
total 8.0K
-rw-r--r-- 1 rbu rbu  29 2009-04-01 17:24 doc1
-rwx--x--x 1 rbu rbu 181 2009-04-01 17:25 some-bin

rbu@localhost ~/copy-example $ copy doc1 some-bin
cat&lt;&lt;E=O=F | perl -MMIME::Base64 -e 'print MIME::Base64::decode(join("", &lt;&gt;))' - | tar xj
QlpoOTFBWSZTWbDjvy4AANl///6/SH1QLn+oZAgORH7jngCAcExyZEJgBABAYABqMEQJMAEbbbMN
QKR5TaEwAn6oxGaGiYAQDCNPTSY9QmTT0AaptKbUxGhHoaAE0aY0AAAEMJowEYTJglEinqD1Mgeo
ZGagAHqM0RkyNAD1D1PUADynlMBeffJ2xSkqIiZOGCIOv87QvSzIWsqS1GG4qIB55xMGD5cgy2Ya
IgH0wmmgmcKCEZJL0BilCat4n/ubxlVIXfIgMCABOZxo2zA0pK5IxR1+ikXrUe7bmHxeL1jyK6fe
fcO0xLbzPXYIxokkI+yKJynt03pqRDZQfBMbvdEaBRQwjQZvEhdVNDcIAOAhVyeeaKerlMFSJYBM
56ibgEosooEIAO8PC9oAbQmOVk8YoGRBgkN9wH8oaOxCgeCuu6VCljLtzvDSGdIYGcPOgRVh+LBi
u/AotDOnl/uuQtH7Md37RU6SE4jjPOLUEHLj0OIOKTNkqk1FiehcQSg62CAQ/4u5IpwoSFhx35cA
E=O=F</pre>
<p>On the remote host you can simply paste this code:</p>
<pre>buchholz@remotehost:~/target-dir$ ls -l
total 0
buchholz@remotehost:~/target-dir$ cat&lt;&lt;E=O=F | \
   perl -MMIME::Base64 -e 'print MIME::Base64::decode(join("", &lt;&gt;))' - | tar xj
&gt; QlpoOTFBWSZTWbDjvy4AANl///6/SH1QLn+oZAgORH7jngCAcExyZEJgBABAYABqMEQJMAEbbbMN
&gt; QKR5TaEwAn6oxGaGiYAQDCNPTSY9QmTT0AaptKbUxGhHoaAE0aY0AAAEMJowEYTJglEinqD1Mgeo
&gt; ZGagAHqM0RkyNAD1D1PUADynlMBeffJ2xSkqIiZOGCIOv87QvSzIWsqS1GG4qIB55xMGD5cgy2Ya
&gt; IgH0wmmgmcKCEZJL0BilCat4n/ubxlVIXfIgMCABOZxo2zA0pK5IxR1+ikXrUe7bmHxeL1jyK6fe
&gt; fcO0xLbzPXYIxokkI+yKJynt03pqRDZQfBMbvdEaBRQwjQZvEhdVNDcIAOAhVyeeaKerlMFSJYBM
&gt; 56ibgEosooEIAO8PC9oAbQmOVk8YoGRBgkN9wH8oaOxCgeCuu6VCljLtzvDSGdIYGcPOgRVh+LBi
&gt; u/AotDOnl/uuQtH7Md37RU6SE4jjPOLUEHLj0OIOKTNkqk1FiehcQSg62CAQ/4u5IpwoSFhx35cA
&gt; E=O=F
buchholz@remotehost:~/target-dir$ ls -l
total 8
-rw-r--r-- 1 buchholz buchholz  29 Apr  1 17:24 doc1
-rwx--x--x 1 buchholz buchholz 181 Apr  1 17:25 some-bin</pre>
<p>And now for the shell action to do this (in ZSH):</p>
<pre>function copy() {
        STR=$(tar cj $@ | perl -MMIME::Base64 -e 'print MIME::Base64::encode(join("", &lt;&gt;))' \
            - ; exit $pipestatus[1] ) || return $?
        echo "cat&lt;&lt;E=O=F | perl -MMIME::Base64 -e \
             'print MIME::Base64::decode(join(\"\", &lt;&gt;))' - | tar xj"
        echo "$STR"
        echo "E=O=F"
}</pre>
<p>If you are using bash, you need to replace &#8220;exit $pipestatus[1]&#8221; with &#8220;exit $PIPESTATUS&#8221; :-/</p>
]]></content:encoded>
			<wfw:commentRss>http://rrr.thetruth.de/2009/04/remote-copy-without-scp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
