This doesn't look like expect code. It looks like regular old read-the-file-regex-output code. So, you may be missing the cool expect features.
I have a guess: ssh and Expect can't really know what's prompt and what's command output. It's all a stream on stdout. You probably have to clear a buffer or something like that after you log in but before you run the command. It's significant that it's the 1st line on server2, because that's what you'd expect to see if you logged in and typed a command.
Does it always happen on server2? If so, it might be a shell setting specific to that account and that server.
Finally, you could just regex out the prompt from the input. You don't need to worry about speed so an extra regex on each line won't hurt anyone.
Really Finally, you could scrap SSH::Expect and use ssh with public keys instead of passwords. That might set up the environment better and not show you the prompt. Since you're not really using the expect features, that might be an easier way to go.
In reply to Re^3: Net::SSH::Expect output
by pileofrogs
in thread Net::SSH::Expect output
by sierpinski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |