Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am copying directories from a Snow Leopard machine to a Tiger machine using scp -r and for some reason, it appears that the final line of the target (Tiger) machine's /etc/bashrc (echo '') causes scp to hang. When commended out, it works as expected.

Why?

I've never seen this behaviour on any of my Slackware, Ubuntu, Gentoo, SuSE, Mandrake or even Apple machines. Is this part of a recent 10.6 security update? scp worked as expected with that line until recently.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This one looks like your issue:

You really shouldn't output stuff in your profile unless you are going in interactively. It appears that SCP is sensitive to it (potentially, depending on a lot of factors, I'm sure). You can test for interactivity thusly:

Text copied out for reference:

To determine within a startup script whether Bash is running 
interactively or not, examine the variable $PS1; it is unset in non-
interactive shells, and set in interactive shells. Thus:

if [ -z "$PS1" ]; then
        echo This shell is not interactive
else
        echo This shell is interactive
fi

Alternatively, startup scripts may test the value of the `-' special 
parameter. It contains i when the shell is interactive. For example:

case "$-" in
*i*)    echo This shell is interactive ;;
*)  echo This shell is not interactive ;;
esac
share|improve this answer
    
This output problem is totally new to me. Furthermore, fortune-mod has been spitting out fortunes from /etc/bashrc since fink was born, and scp never output it. Nevertheless, I think your advice is sage and I'll take it. Thanks! –  msanford May 12 '11 at 20:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.