Command shells in the sh family execute ~/.profile and ~/.bash_profile
once at login, and ~/.kshrc and ~/.bashrc when ever a new shell
starts. Command shells in the csh family execute the ~/.login on
login, and the ~/.cshrc when ever a new shell starts. When a user logs
into a server the shells reads these initialization files: ~/.kshrc,
~/.bashrc, or ~/.cshrc followed by the ~/.profile, ~/.bash_profile or
~/.login depending on the shell.
.profile, .bash_profile, .login: used to identify the terminal and set
the erase character
.cshrc, .kshrc, .bashrc: used to set shell variables and aliases
If you see "stty : : Invalid Argument," it means your ssh command
logged into the remote server (non-interactive) and initialized the
shell, but encountered stty in one of the scripts above. It's a non-
interactive shell, there is no control terminal.
Look in the scripts mentioned above for a stty. You'll find it because
this is why you're getting the "stty : : Invalid Argument." You can
remove the line, or check for interactive or non-interactive:
if [ -t 0 ]; then
echo interactive
stty erase ^H
else
echo non-interactive
fi
-t fd - True if file descriptor fd is open and refers to a terminal
Or you just discard the error messages
stty erase ^H 2>/dev/null
Bye, Jojo
Thanks! How reliable is this? I mean, is it likely for and
non-interactive shell have its 0 fd redirected to tty, and
conversely for an interactive shell have its 0 fd redirected to
a non-tty?
There is other way to check for interactivity:
case $- in
*i* ) INTERACTIVE=1 ;;
esac
And this apparently works (although no idea what 255 fd for):
if [ -t 255 ]; then INTERACTIVE=1 ; fi
--
(stephan paul) Arif Sahari Wibowo
_____ _____ _____ _____
/____ /____/ /____/ /____
_____/ / / / _____/ http://www.arifsaha.com/
Awesome, I'll have to try this. The redirection that you mentioned
could be done, but why? I'm assuming, I guess, a normal baseline for
initializing a shell.
I know the error message can just be discarded, but I wrote this
thread to try to educate others that wonder why they're seeing the
message.