in reply to regular expression matching in expect
Am i taking the right approach
Having done a lot of this, I would:
- Set up an ssh-key, to log in automatically without Expect - as a non-root user.
- Write one Expect script for each of the (few?) commands that are interactive.
- Write one straightforward wrapper to tie it all together.
- Enable the non-root user to run the wrapper with sudo.
Something like this:
ssh admin@host "sudo /path/to/wrapper.pl"
Where the wrapper might:
die("...") if system("/path/to/cmd1.sh")!=0;
die("...") if system("/path/to/interactive-cmd-exp.pl")!=0;