I don't know why it isn't working.
I would not embed passwords in a script - particularly root passwords. Therefore I wouldn't try to solve the problem you are experiencing.
I would use public key authentication to enable automated access on a remote system, particularly in the case of root access. I might also use sudo to enable select commands for non-root users, rather than su to root.
In reply to Re: Change user to root using ssh::expect
by ig
in thread Change user to root using ssh::expect
by want2bemonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |