Not sure how to deal with large blocks of text awaiting script

I am trying to write a wait script to automate the WowzaStreamingEngine installer. Running the installer outputs long (some might say absurdly long) EULAs, which require some interaction - accepting the EULA, setting the username and password, repeating the password, and setting whether to start at boot. I have recorded my steps with autoexpect, but I have a couple of problems. First, it will only work in the same terminal that I ran autoscript on (I assume this is because autoexpect was writing a certain number of lines each time I pressed spacebar to advance the script past the absurdly long EULA), but the script didn’t will be completed - it gets to the last question and just hangs. Here is the complete, unmodified script (interop, excluding whitespace, starts at line 1284):

http://pastebin.com/uWk7vyZW

I tried to cut out all blocks of text by shrinking the script to the point where only questions requiring interaction are included:

http://pastebin.com/dsUqQ0WX

but does not get past the first block of text in the EULA.

The closest I came to complete the script, cut out whatever appeared after the last interactive prompt (I posted a third link, but I need more reputation points to send 3 links).

I seem to go back to the user prompt, but it doesn't work - I need to cntl-c go to the functional user prompt.

Any help or guidance is greatly appreciated.

+3


source to share


2 answers


Similar to Dinesh's answer, but you don't need to create a wrapper, so it's even simpler:

#!/usr/bin/expect -f

set timeout -1
spawn sudo ./WowzaStreamingEngine-4.1.2.deb.bin

expect {
    -gl "*--More--*" { send -- " "; exp_continue }
    -ex "Do you agree to the above license terms?"
}
send -- "yes\r"
expect -gl "*User Name: "
send -- "UserName\r"
expect -gl "*Password: "
send -- "password\r"
expect -gl "*Confirm Password: "
send -- "password\r"
expect -gl "*Please enter a Wowza Streaming Engine license key*"
send -- "license key\r"
expect -ex "Start Wowza Streaming Engine automatically when this system reboots?"
send -- "yes\r"

expect eof

      



Trimming the generated autoexpect script can be a bit of an art.

+1


source


With exp_continue

all of your needs will be met shortly. This will cause it to restart expect

. Using this, we can simplify the script like this:

set timeout 300; # Setting 'timeout' to 5 mins
set prompt "#|>|\\\$"; # We escaped the `$` symbol with backslash to match literal '$'
set linuxPassword "yourpassword"
spawn /bin/bash; # spawning 'bash' shell here
expect -re $prompt
send "sudo sh WowzaStreamingEngine-4.1.2.deb.bin\r"
expect {
        "password for $tcl_platform(user): $"  {send "$linuxPassword\r"; exp_continue}
        -- "--More--" {send " "; exp_continue}
        "\\\[yes or no]" {send "yes\r"; exp_continue}
        "User Name: $" {send "username\r"; exp_continue} 
        "Password: $" {send "password\r"; exp_continue} 
        "enter a Wowza Streaming Engine license key" {send "license-key-here\r"; exp_continue}
        -re $prompt {puts "INSTALLATION COMPLETED SUCCESSFULLY"}
        timeout {puts "TIMEOUT HAPPENED"}
}       

      

Symbols

$

and [

important for both Tcl

, and for expect

, so it is reset with a backslash simple. \\\$

will match literal $

, likewise \\\[

will match literal[

Here we have to be careful with the timeout. I set it to 5 minutes and during that interval all our required templates should be matched. Otherwise, the timeout will happen for sure. You can change as timeout

per your requirement.



Note. I tried to test this setup on my computer where I got stuck with the Username part. After assigning a username, it throws an error like

A password is required. Please try again.
WowzaStreamingEngine-4.1.2.deb.bin: 1242: read: Illegal option -s

      

Due to this, I cannot check my code to the end. So, check and let me know about the changes.

+2


source







All Articles