I have an expect script that is exiting, instead of processing text that is sent and installing files. I'm trying to figure out why it's not installing files, i.e. not implementing what would be done had I run the process manually instead of via expect.
I have the following code in my script:
#!/usr/bin/expectset exp_internal 1set timeout 30set java [lindex $argv 0];set installer [lindex $argv 1];spawn $java -jar $installer -consoleexpect {"*More*" { send " "; exp_continue }"Press 1 to accept, 2 to reject, 3 to redisplay" { send "1\r" }}expect "Select the installation path:*" { send "/opt/pentaho8.3\r" }expect "Press 1 to continue, 2 to quit, 3 to redisplay\r\n" { send "1\r" }closeexit
When I run the script as follows:
$ sudo /usr/bin/expect -d install-pentaho.expect /usr/java/jdk1.8.0_261/bin/java pentaho-server-manual-ee-8.3.0.0-371/installer.jar
It runs as expected, except for the last couple lines:
send: sending "/opt/pentaho8.3\r" to { exp6 }expect: does "" (spawn_id exp6) match glob pattern "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"? no/opt/pentaho8.3expect: does "/opt/pentaho8.3\r\r\n" (spawn_id exp6) match glob pattern "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"? noPress 1 to continue, 2 to quit, 3 to redisplay expect: does "/opt/pentaho8.3\r\r\n\r\nPress 1 to continue, 2 to quit, 3 to redisplay\r\n" (spawn_id exp6) match glob pattern "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"? yes expect: set expect_out(0,string) "Press 1 to continue, 2 to quit, 3 to redisplay\r\n" expect: set expect_out(spawn_id) "exp6" expect: set expect_out(buffer) "/opt/pentaho8.3\r\r\n\r\nPress 1 to continue, 2 to quit, 3 to redisplay\r\n" send: sending "1\r" to { exp6 }
Anyone have thoughts as to why the '1' being sent by expect is getting ignored? It seems that the spawned process is exiting, ignoring the '1' that is sent.
Below is the expected output, i.e. what I get when I run sudo /usr/java/jdk1.8.0_261/bin/java -jar pentaho-server-manual-ee-8.3.0.0-371/installer.jar
-console manually:
Select the installation path: [/root/pentaho/pentaho-server-manual-ee-8.3.0.0-371]/opt/pentaho8.3Press 1 to continue, 2 to quit, 3 to redisplay1────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Installation────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────[ Starting to unpack ][ Processing package: Base (1/1) ][ Unpacking finished ]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Installation Finished────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Installation was successfulApplication installed on /opt/pentaho8.3[ Console installation done ]
Any thoughts on why the installation is not occurring, and the expect script is exiting prematurely?