I need some help with he expect command. I am trying to unpack the teamspeak 3 Linux client automatically.

Here is my script to grab the file


mkdir /home/test && cd /home/test
wget http://dl.4players.de/ts/releases/
chmod 0777 TeamSpeak3-Client-linux_amd64-

Here is my expect script that gets executed after the script above ...

#!/usr/bin/expect -f
spawn sh TeamSpeak3-Client-linux_amd64-
expect "\[RETURN\]"
send "\r"
expect ":"
send "q"
expect "Please type y to accept, n otherwise:"
send "y\n"

It does NOT uncompress and it should.

Thank you so much!

  • 1
    Make send "q\r" and send "y\r", assuming the expected strings are correct. – heemayl Sep 5 '16 at 20:12
  • 1
    @heemayl it appears the first one doesn't need the \r (the q just quits the less pager that's used to display the agreement); adding it just makes it present the y/n question twice. – steeldriver Sep 5 '16 at 20:28
  • @steeldriver Ahhh, makes sense. I didn't check the the script though. – heemayl Sep 5 '16 at 20:31

This seems to work, for me (I haven't tested the final installation)

#!/usr/bin/expect -f

spawn ./TeamSpeak3-Client-linux_amd64-
expect "\[RETURN\]" {send "\r"}
expect ":" {send "q"}
expect "otherwise:" {send "y\r"}
expect eof {exit}
  • Most excellent! Thank you so very much for this answer and the other reply which bright me here. I really appreciate so very much, you have no idea. – curiouscat Sep 5 '16 at 21:15
  • @curiouscat you're welcome - I posted a further comment on your original question suggesting a way to do it without expect (by tricking less into quitting right away) – steeldriver Sep 5 '16 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.