[UCI-Linux] scp and .bashrc verbosity

Francisco Lopez lopez at uci.edu
Mon Jun 22 16:51:52 PDT 2009


Harry,

Usually, checking for a tty is sufficient, e.g.

if tty -s
then
    ./run-interactive-commands
fi

Sincerely,

	-Francisco


on 6/17/09 10:03 AM Harry Mangalam said the following:
>>From the " ..so you won't mess up like I did" files..
> 
> I was playing around with my .bashrc to make it more useful for when I 
> logged in (automatically tell me what hosts on the cluster are down, 
> who's logged in, and what the Q status is.
> 
> That all worked fine, but I also found out that it interfered with 
> scp - when I tried to scp some files to that host, scp hung.  In 
> debugging this problem, I eventually found out that .bashrc lines 
> that emit text can (and apparently do) interfere with scp (and other 
> processes that expect a mute shell response).  So one example is to 
> put all your text-emitting stuff in a separate file and 
> execute that file only if you can detect a tty.  
> 
> See: <http://defindit.com/readme_files/bash_examples.html>
> 
> ie hide the execution of that file inside a test like:
> 
>  ...
> # yes we could do this in one line, but readability counts
> interactive=`echo $- | grep -c i ` 
> if [ ${interactive} = 1 ]; then
>     ./whutsup.sh # where whutsup.sh emits all the text
> fi
>  ...
> 
> If there are more elegant ways of doing this, please let me know.
> 
> But it seems that snazzy prompt strings don't interfere with scp:
> 
> bash this (in one line)
> 
> PS1="\n\[\033[01;34m\]\t \[\033[01;32m\]\u@\[\033[01;31m\]\h:\[\033
> [01;33m\]\w\n\! \$ \[\033[00m\]"
> 
> 


More information about the UCI-Linux mailing list