Re: : Invalid argument Using SSH



John Doe wrote:
In a script, I was using SSH to run a command on a remote server. I
got the message "stty : : invalid argument." It took me a while to
figure out why. An interactive shell reads commands from user input on
a tty. If you're executing ssh inside a script to run a command on
another server, ssh logs into the server as a specific user, and
executes the command on the server in a non-interactive shell.

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


.



Relevant Pages

  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... the phrase "it does not work anymore" carries very little meaning. ... after compilation and execution of the shell with a simple command like ... all the command in the file are executed as well. ...
    (comp.lang.c)
  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... the phrase "it does not work anymore" carries very little meaning. ... after compilation and execution of the shell with a simple command like ... all the command in the file are executed as well. ...
    (comp.lang.c)
  • Re: shell scripting
    ... and am assuming an sh-compatible shell here.... ... command 1 options arguments ... To run the script, do: ... then you need to use the full path to execute it: ...
    (comp.unix.questions)
  • Re: shell scripting
    ... and am assuming an sh-compatible shell here.... ... command 1 options arguments ... To run the script, do: ... then you need to use the full path to execute it: ...
    (comp.unix.shell)
  • Bash-4.0 available for FTP
    ... Unlike previous bash distributions, this tar file includes the formatted ... The shell has been changed to be more ... rigorous about parsing commands inside command substitutions, ... Changes have been made to the Readline library being released at ...
    (gnu.announce)