<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>scp &amp;mdash; alan</title>
    <link>https://www.franzoni.eu/alan/tag:scp</link>
    <description>Alan&#39;s musings</description>
    <language>en</language>
    <pubDate>Tue, 17 Nov 2026 00:37:13 +0000</pubDate>
    <item>
      <title>SCP taming: stop local silliness</title>
      <link>https://www.franzoni.eu/alan/scp-taming-stop-local-sillyness</link>
      <description>&lt;![CDATA[Every day now and then, I get an scp command wrong. Scp is designed after commands like rcp and works totally fine for local-to-local file copy.&#xA;&#xA;While this can (or could) be useful in some contexts, It&#39;s not what I like to do these days; very often, if either hosts is not remote, it&#39;s a typo on my part, and results in spurious &#34;somebody@host.example.com&#34; files somewhere in various directories on my disk.&#xA;&#xA;So, what I like to do? I put a small script like this in my path before the actual scp executable in order to pre-check arguments, and prevent accidental local-only copies.&#xA;&#xA;!/bin/bash&#xA;ORIG=&#34;/usr/bin/scp&#34;&#xA;&#xA;for var in &#34;$@&#34;&#xA;do&#xA;    if [[ $var = &#34;:&#34; ]]; then&#xA;        $ORIG &#34;$@&#34;&#xA;        exit $?&#xA;    fi&#xA;done&#xA;&#xA;echo &#34;ERROR: Missing colon. You need to pass at least one remote host specifier in source or dest&#34;&#xA;exit 1&#xA;&#xA;#MostlyUnixish #ssh #scp&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Every <del>day</del> now and then, I get an <strong>scp</strong> command wrong. Scp is designed after commands like <a href="https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.cmds4/rcp.htm" rel="nofollow">rcp</a> and works totally fine for local-to-local file copy.</p>

<p>While this can (or could) be useful in some contexts, It&#39;s not what I like to do these days; very often, if either hosts is not remote, it&#39;s a typo on my part, and results in spurious “<a href="mailto:somebody@host.example.com" rel="nofollow">somebody@host.example.com</a>” files somewhere in various directories on my disk.</p>

<p>So, what I like to do? I put a small script like this in my path <em>before</em> the actual scp executable in order to pre-check arguments, and prevent accidental local-only copies.</p>

<pre><code class="language-bash">#!/bin/bash
ORIG=&#34;/usr/bin/scp&#34;

for var in &#34;$@&#34;
do
    if [[ $var = *&#34;:&#34;* ]]; then
        $ORIG &#34;$@&#34;
        exit $?
    fi
done

echo &#34;ERROR: Missing colon. You need to pass at least one remote host specifier in source or dest&#34;
exit 1
</code></pre>

<p><a href="/alan/tag:MostlyUnixish" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">MostlyUnixish</span></a> <a href="/alan/tag:ssh" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ssh</span></a> <a href="/alan/tag:scp" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">scp</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/scp-taming-stop-local-sillyness</guid>
      <pubDate>Thu, 26 Apr 2018 10:38:49 +0000</pubDate>
    </item>
  </channel>
</rss>