| |||||||||||
expect, automate ssh login Posted by monteo7 (monteo7), 4 March 2008 Hello, I'm trying to automate the login of ssh and then interact when a prompt is reached. I don't know what I'm expecting while logging in (password prompt or ssh key) so loop through these. This script prompts you for a username, password and host, then runs expect. I want to exit the login loop once a prompt is reached, run the "uname" command and then (hopefully) interact.code button not working for me, will these code tags work? Code:
Posted by admin (Graham Ellis), 4 March 2008 You might find it easier to put your expect script into a separate file and test it on its own rather than embedding it within a Korn shell script. Tcl quoting is bad enough without adding a ksh level too!Posted by monteo7 (monteo7), 5 March 2008 I have put my code in a separte expect script and it still fails because the issue is the expect loop, not ksh. If I put the following into expect it still fails, again, not sure how to exit expect loop and initiate interaction. Are there for or while loops in expect? I could possbile do something like this:for (i=0; i<2;i++): then loop through twice and automatically exit...?? Code:
Posted by admin (Graham Ellis), 5 March 2008 exp_continue tells it to loop. If you remove the exp_continue, it will break out of the loop. And if you want to keep expecting until you have some counter up to (say) 2, write of the formset counter 0 while {$counter < 2 } { expect ..... to include incr counter were appropriate } This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |