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
?