2

I am executing a command through script in remote server which is of non-interactive mode. I've gone through the link and found the below errror is because of running stty in non-interactive mode.[URL="http://compgroups.net/comp.unix.shell/stty-invalid-argument-using-ssh/506594"]http://compgroups.net/comp.unix.shell/stty-invalid-argument-using-ssh/506594[/URL]

stty -echo 
useradd <useraname> -m <password>
stty echo

stty is used not to show passwords in terminal. But i am getting stty: standard input: Invalid argument as in output.

How to get rid of/overcome this error in my output.

Shriram
  • 4,343
  • 8
  • 37
  • 64
  • `stty` works fine in non-interactive scripts. It's a script (interactive or not) that is not connected to a controlling tty that is going to have problems with `stty`. Non-interactive is not necessarily equivalent to "no controlling tty"... – twalberg Nov 10 '14 at 15:30

1 Answers1

1

echo is for whether locally typed characters are displayed on the screen or not (as far as I know).

I don't believe that does anything for a script that includes a password in it already.

So you can probably just remove those two stty lines entirely as they aren't doing anything useful for you to begin with.

Alternatively, if, for some reason, there is (or you believe there is) a reason to keep those lines you should be able to add 2>/dev/null to those commands to silence the error output.

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148