0

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

#!/bin/sh

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

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

#!/usr/bin/expect -f
spawn sh TeamSpeak3-Client-linux_amd64-3.0.19.4.run
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!

3
  • 1
    Make send "q\r" and send "y\r", assuming the expected strings are correct.
    – heemayl
    Sep 5, 2016 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. Sep 5, 2016 at 20:28
  • @steeldriver Ahhh, makes sense. I didn't check the the script though.
    – heemayl
    Sep 5, 2016 at 20:31

1 Answer 1

2

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

#!/usr/bin/expect -f

spawn ./TeamSpeak3-Client-linux_amd64-3.0.19.4.run
expect "\[RETURN\]" {send "\r"}
expect ":" {send "q"}
expect "otherwise:" {send "y\r"}
expect eof {exit}
2
  • 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, 2016 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) Sep 5, 2016 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .