How to start a shell script within "expect script"?

user3636706 picture user3636706 · May 14, 2014 · Viewed 14.3k times · Source

In this expect script there will be no ssh server connected, I just want to execute a ".sh" file locally, is that possible?

For instance:

#!/bin/expect

command "xxx.sh" # a command which starts a certain shell script

Also, is it possible to execute a expect script within a expect script?

For instance:

#!/bin/expect

command "xxx.exp" # a command which starts a certain expect script

Any help?

Answer

glenn jackman picture glenn jackman · May 14, 2014

If you need to interact with this script, use spawn xxx.sh

If you just need to run it and capture the output, use set output [exec xxx.sh]

Expect is an extension of the Tcl language, so you would be well served to go through the Tcl tutorial.