From: ivo w. <ivo...@br...> - 2008-09-23 00:57:59
|
Dear Roland: Thanks a lot for taking care of this module. It seems incredibly useful, so I am now trying to learn it. Alas, not easy to figure out. One of the most common uses of Expect is probably use of "ssh" under linux with a password that sits in my program. So, I am trying to figure out from the docs what the recommended way to do this is. Therefore, I think this could be a good candidate for an example. It is probably obvious to the initiated, but not so to those of us that don't even know the TCL Expect command. The logic of executing ssh would seem to suggest that I need to look for: "Are you sure you want to continue connecting (yes/no)?" to which I would answer "yes". This prompt may or may not appear. "Password: " to which I would give my password. This may or may not appear the first time. "Password: " a second time, which would lead me to die the program (I had the wrong password). EOF which should make me return happily. It is not at all obvious to me how I would write a function run_sshcommand( $remotecommand, $remotepassword ) that automates this. From the docs, it is not easy to see if multiple arguments to expect are sequential, or alternatives. Also, some statements suggest I need "-re", other examples seem to suggest that I can use qr//; Any help would be appreciated. Regards, /iaw |