0
I have an expect script that spawns a process, then does some initialization (authentication), then performs some task that needs prior authentication.
Considering to extend the script to execute multiple tasks after initialization, I wondered whether I could use separate expect processes to perform each task (once the spawned process terminates it needs to re-authenticate).
So that would mean:
First expect spawns a process and does initialization. Then expect exists, but leaves the spawned process active.
For each task to perform: Start another expect process that re-attaches to the process spawned earlier. This step would repeat as often as needed.
A final expect re-attaches to the spawned process and does a clean shutdown of that process.
Is that possible? The advantage would be that for many tasks, a script could be created on the fly, being executed, and then replaced by the next task's script. Otherwise I would have a very lengthy script...
Not unless you spawn your command wrapped in [tag:tmux] or [tag:screen] – glenn jackman – 2020-01-29T17:53:36.287
Be aware that expect's
interact
command can listen for patterns and automatically do stuff, that may help. – glenn jackman – 2020-01-29T17:54:16.607On tmux and screen: Could you give an example, maybe using
ssh
to log in to some host "interactively", the send more commands to the ssh connection? I'm not quite sue how a solution might look like. – U. Windl – 2020-02-02T00:04:57.050You'll be better served doing some research, of ask a separate question. – glenn jackman – 2020-02-02T00:24:02.993
Just one note:
https://superuser.com/questions/tagged/screen
refers todisplay
issues, which most likely not what you had in mind. – U. Windl – 2020-02-02T01:38:31.373