For example, now I have a "root.exp" expect script as following:
spawn ssh user@ip
expect "Password:"
send "password"
Then, the expect command I want to send to this ssh server is stored in another expect script file branch.exp, which for example is as following:
expect ">>"
send "ls"
My question is, how to call this branch.exp in root.exp? For example, something like following in the root.exp:
spawn ssh user@ip
expect "Password:"
send "password"
*call* branch.exp
As Johannes said, you can use the source command. The Expect and TCL mini reference manual says:
source Procedures and variables can be stored in other files and read using the source command. As the file is read, the commands are executed.
Example:
source ~/def.tcl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With