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 !