Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

Ok, so I have used linux for a long time but this is the weirdest thing I have encountered in a long time. Maybe I just don't do a lot of scp so probably missing something simple here. So in my .bashrc file I have the following.

export KERNEL=$(uname -r)
if [ $KERNEL == "2.6.32-431.3.1.el6.x86_64" ];then
   ... logic here
    .. more logic

Now if I uncomment that echo line then the following command doesn't work! It just shows the echo but doesn't do any copying. If I remove that line it does the copy

$ scp -r /tmp/user/sim/dir1
HOST: KERNEL VERSION: 3.4.70-1.el6.companyX

$ scp -r /tmp/user/sim/dir1

pybackup 100% 174 0.2KB/s 00:00
Proxy.ini 100% 623 0.6KB/s 00:00

This is strange...

share|improve this question
I happened to find a good answer here: – Spiff Mar 17 '14 at 17:32
thanks for this. Good to know I wasn't losing it :) – bjackfly Mar 17 '14 at 21:37

Using echo in a .bashrc will break scp, as scp expects to see its protocol data over the stdin/stdout channels. See and this post for more discussion on this issue.

There's a few workarounds available, how to use echo in a scp-safe manner in .bashrc:

case $- in *i*) echo Hello World ; esac
tty >/dev/null && echo Hello World
if [ -t 1 ]; then echo Hello World ; fi
share|improve this answer

You must log in to answer this question.

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