in reply to Re^2: Expect OpenSSH sudo login is failing
in thread Expect OpenSSH sudo login is failing

I suspect that I may have found the root cause, at least it is 'kind of' working now that I have made the following change:

[ qr/$rootpassword/ => sub { shift->send("$password\n");} ],

Changed to:

[ qr/$rootpassword/ => sub { shift->send("$rootpassword\n");} +],

So it may have in fact been the wrong password