Mollien dot Net is IPv6 Enabled!


   My About.Me page
   View my profile on LinkedIn
   Follow me on Twitter
    View my Facebook profile   View my Hyves profile   View my YouTube favorites and uploads

      01010011
      01100101
      01110010
      01101001
      01101111
      01110101
      01110011
      01000111
      01100101
      01100101
      01101011

IPv6 Certification Badge for Cas Mollien
 


 
Software
 
Detecting an interactive session over SSH
 
If you use SSH to connect to remote hosts and have an extensive .bashrc file that echos out some nice lines as soon as you log in, you will find that this gives problems when using SCP from the command line or WinSCP using Windows.

When using SCP, file transfers do not always take place because SCP chokes on the information that is spit out by the .bashrc script. This causes the file transfer to be interrupted.

What I have done in the past, is log on over SSH, rename the .bashrc file, perform the file transfer and rename the file back. There has to be a better way....

The better way that I found was by using the shopt (SHell OPTions) command and adding that to the .bashrc file.

The command 'shopt -q login_shell' is a quiet way of detecting if you are using a login shell or a process, such as SCP. By encapsulating your output in a test, using the output of this command, you can stop the echo taking place. e.g.:

if shopt -q login_shell ; then
echo -e "${CYAN}This is BASH ${RED}${BASH_VERSION%.*}\
${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n"
fi

At this point, you can SCP files without the process flaking out because of the additional lines.

** One problem with this approach: A shell on a local computer is not considered a login shell, so while .bashrc is being loaded, nothing is being echoed..... Solution to bu updated shortly.
 
Found this script/snippet useful? Please consider buying me a beer - or something else useful..
 

 
Terug naar Mollien Dot Net

Terug naar Mollien Dot Net

Terug naar Mollien Dot Net
Total Hits: 1
Unique Visitors: 1
Page Impressions : 1
Remote address: 54.82.56.95