Friday, October 08, 2004

SSH issues

sftp and scp don't work if the shell isn't "clean", i.e the initialization files spit out characters on the stdout.
To handle this we need to ensure that in the case of non-interactive invocation of shell no output is produced .

To do this following check may suffice
if [ "SSH_TTY" = "" -a "PS1" !="" ]; then
fortune........
fi
This ensures that stdout is cluttered only when we have no tty attached to the shell and its not a non-interactive login.

A more reliable way to check non-interactive nature of shell is to look at the value of $-.
This variable contains 'i' for interactive logins.