in reply to Re: send su password in sshin thread send su password in ssh
I have used Net::SSH::Expect to perform this task with both key-based and password authentication.
Any expect-capable script should resolve any of your timing concerns.