0

I have lately been working on a "scripts" project to isolate and improve maintainability of all the bash shell tools and third party software versions we need so you'd source this e.g. /opt/dev/scripts/tools.sh from your .bashrc and you get all up to date environment variables for software versions etc etc. As part of this exercise I thought it was a good idea to print a message in tools.sh displaying the current version of the scripts i.e.

echo "************* Running Scripts version $SCRIPTS_VERSION *************"

The problem is that after doing this. All tools including rcp would show this message and rcp did not work. Why? The only way to fix it was to print the message only when the script was executed from a terminal and not from others like ssh, rcp etc.

# only show version if running from a console, print only when 
# parent contains 'terminal' 
PARENT=`ps --no-heading -o %c -p $PPID`
if [ `echo $PARENT | grep 'terminal'` ]; then
  echo "************* Running Scripts version $SCRIPTS_VERSION *************"
fi

Can anyone explain why rcp stops working if my .bashrc prints a message using echo?

SkyWalker
  • 13,729
  • 18
  • 91
  • 187
  • Try printing the information to standard error instead: `echo ... >&2` – choroba Nov 28 '14 at 16:28
  • 1
    possible duplicate of [SCP doesn't work when echo in .bashrc?](http://stackoverflow.com/questions/12440287/scp-doesnt-work-when-echo-in-bashrc) – Kenster Nov 29 '14 at 12:48
  • Indeed possible duplicate seems very similar ... however, it is nice to show the same problem occurs with a different tool in this case the `rcp` tool, or? – SkyWalker Nov 29 '14 at 16:02

0 Answers0