Stop tcsh log in script from interrupting scp

By: | Comments: No Comments

Posted in categories: Computer Tips, Work related

If you are using tcsh shell, and your login script has screen output like an echo line, scp will be interrupted.

To prevent this, knowing that for an interactive ssh session, it will open a tty, but embedded session like scp will not generate a tty.

Thus this can be distinguished by checking if the variable $SSH_TTY is defined. For example, you can put this in your ~/.cshrc

if ($?SSH_TTY) then
(do your login environment settings here)
else
set sh = /bin/bash
set cmdline = “tr '\0\n' '\n\1' </proc/$$/cmdline
if ($#cmdline > 2) then
exec $sh -c ‘exec “$0” -c “$(printf %s “$1” | tr “\1” “\n”)”‘ $sh $cmdline[3]:q
endif
endif

This, will launch a log in script free session for embedded sessions like scp.

Be the first to comment!

Leave a Reply