Calling expect scripts from other expect scripts
First, let me explain the issue I am trying to solve. We have a lot of expect scripts with the duplicated send/expect commands. So, I'd like to be able to extract the duplicated code into the common scripts that can be used by other scripts.
Below is my test where I am trying to call b.exp from a.exp:
set timeout 5
send -- "./b.exp $spawn_id\r"
set spawn_id [lrange $argv 0 0]
send -- "ls -al\r"
I am passing the spawn_id into the b.exp script and then sending the "ls" command. The "ls" command does not output anything, so I understand that I can't pass just like that the handle to the process from one expect script to the other.
Could you suggest any other approach to solve my original issue or maybe there's actually a way to talk to the same process from the distinct expect scripts?