in reply to rlogin followup

I have never used it, but I think you could download and read the documentation of Expect