0

I have a problem that I want to execute an "expect script" inside of an expect script. Is there anyway to do this? I appreciate any help.

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
user3636706
  • 197
  • 1
  • 2
  • 15
  • 1
    Can you show what you have done so far? – Chris Mann May 14 '14 at 12:55
  • You can use `exec` or `source`, depending on if you want your current expect script to be affected. See http://tcl.tk/man/tcl8.5/TclCmd/contents.htm – glenn jackman May 14 '14 at 16:41
  • Hi guys, thanks very much for your responses! let me explain my question more detail – user3636706 May 14 '14 at 17:10
  • Hi guys, thanks very much for your responses! let me explain my question more detail. I want to write one script that it will first connect to a ssh server, then several testcases(implemented in "expect" scripts), which are stored locally, are to be executed on this server. However due to some reason, these testcases should be written in individual files. So now what I am sure is, these testcases are to be written in "expect" scripts. – user3636706 May 14 '14 at 17:19
  • What I am not sure is, how to first connect to a ssh server, keeping this ssh connection, in the meanwhile execute these testcases which are stored locally. And we are not using the tcl tools, just "expect". – user3636706 May 14 '14 at 17:19
  • Please edit your question instead of putting important details hidden in comments. – glenn jackman May 14 '14 at 20:04
  • possible duplicate of [How to start a shell script within "expect script"?](http://stackoverflow.com/questions/23662020/how-to-start-a-shell-script-within-expect-script) – glenn jackman May 14 '14 at 20:05

1 Answers1

0

[TL;DR]

one sample would help you understand

spawn expect ./runmysql.exp $dbEnv "select * from SalesOrder where orderNo='$orderId' \\G; \r"

Reference for more reading:

https://todzhang.com/blogs/tech/en/expect-script-is-your-secret-to-productivity

Related source:

https://github.com/CloudsDocker/MagnificentExpectScripts/blob/main/call_another_expect_script_from%20_one_expect_script.exp

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
phray2002
  • 425
  • 4
  • 9