Ubuntu – Auto Passing a “q” before a Y on a command line

bashcommand linescripts

I am trying to download the teamspeak 3 client and accept the license agreement routine all at the same time. I know how to pass a “yes” before the script but the routine requires me to press Q to quit the “license agreement” before clicking the Y key to start the unpacking of the client.

cd /home/test/ts3_client_files
wget http://dl.4players.de/ts/releases/
yes 'y' | ./TeamSpeak3-Client-linux_amd64-

As you can see, the routine requires the pressing of Q first. When I press Q, Y is then pressed automatically and the files decompress.

+ cd /home/test/ts3_client_files
+ wget http://dl.4players.de/ts/releases/
--2016-09-05 08:33:26--  http://dl.4players.de/ts/releases/
Resolving dl.4players.de (dl.4players.de)...,,
Connecting to dl.4players.de (dl.4players.de)||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 37054436 (35M) [application/x-makeself]
Saving to: ‘TeamSpeak3-Client-linux_amd64-’

100%[=============================>] 37,054,436  9.56MB/s   in 7.1s

2016-09-05 08:33:34 (4.96 MB/s) - ‘TeamSpeak3-Client-linux_amd64-’ saved [37054436/37054436]

+ chmod 0700 TeamSpeak3-Client-linux_amd64-
+ yes y
+ ./TeamSpeak3-Client-linux_amd64-
Welcome to the TeamSpeak 3 Client for Linux on amd64 installer

In order to install this software you are required to accept the license
agreement, please press return to view the license.

You can scroll with the arrow keys and quit the viewer by pressing 'q'.
Please type y to accept, n otherwise: Creating directory TeamSpeak3-Client-linux_amd64
Verifying archive integrity... All good.
Uncompressing TeamSpeak 3 Client for Linux on amd64  100%
+ exit

Would someone be so kind in showing me the way?

Best Answer

The q keypress serves as a quit signal for the pager less, which is explicitly used by the script:

read FOO
echo "$licensetxt" | less
while true
  MS_Printf "Please type y to accept, n otherwise: "
  read yn
  if test x"$yn" = xn; then
eval $finish; exit 1
  elif test x"$yn" = xy; then

And man less says:

Options are also taken from the environment variable "LESS".

Set this environment variable as follows:

printf '\ny\n' | LESS='+q' ./TeamSpeak3-Client-linux_amd64-

Solution taken from @steeldriver's comment and added according to the law of @JamesTheAwesomeDude.

Related Question