2

I login to some Ubuntu servers via ssh to run installation script. The script contains some lines as below:

echo "deb http://nginx.org/packages/mainline/ubuntu/ bionic nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ bionic nginx" >> /etc/apt/sources.list
...........................................
echo 'mysql-server mysql-server/root_password password xxxxxxx' | debconf-set-selections

apt update
apt install nginx -y
apt install mysql-server -y
............................................

In the first run on the server, I got error "Setting in Stop via TCSAFLUSH for stdin failed! - tcsetattr (5: Input/output error)". All commands were still executed but the terminal output became messy, wrong line breaking, so it was difficult to watch the command output. If I ran this script again, the above error would disappear and the output of terminal would display neatly, line by line.

Although, my script still works, but I need a professional script. How can I fix this error ? Thank you !

1 Answer 1

0

I have a guess. Do you change user at some point in the script? If you do, like 'su root' or something, the current terminal might not belong to that user. Then calls to manipulate the terminal might fail. In this case, the output might be out of order.

Not sure how to fix it though. The transition from regular user to root via su or sudo or whatever should be able to handle that.

Try running 'reset' at the start of your script. Not sure how that would work if I'm right, but it might work if I'm wrong :-)

Other things to check are if TERM is correct. What env vars is SSH propogating from the local machine to the remote.

Good Luck!

1
  • 2
    Thank for your reply. I login into root and run the script. My script doesn't change user. I find that the error appears when run apt install xxxx -y. Options -y is related to stdin, term,... I'm not sure but the error only appear in the first run. Commented Jul 9, 2020 at 10:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.