in reply to Struggling to collect o/p of command using expect.
In the original script you see that in the line corresponding to $exp->expect($timeout, 're', "$user\@cli>"); the 're' is actually '-re'. It is also '-re' in the documentation. '-re' is a parameter to tell Expect to use the following exit patterns as regexes instead of just as search strings. 're' is interpreted just as another exit pattern and since there is a 're' in 'Unconfigu<re>d', Expect stops there
Just remove the 're' and it should work
|
|---|