From: expect <ex...@ih...> - 2003-08-07 17:38:10
|
On Wed, 6 Aug 2003 16:45:26 -0400 "Harter, Douglas" <dh...@st...> wrote: > There is an example of this in the 'Exploring Expect' book, Pg 5, but I > want the differences with ExpectPerl. > > I am a beginner with Unix, Perl, and Expect, but I am trying to cut down my > development time, so wonder if someone can give me an example using > ExpectPerl to set passwords using the Unix passwd command. I am a System > Administrator who could really use a script to set passwords automatically. > I still have to work out getting the modules installed on our system, but if > I can show it can be done, it will help. > > Using TCL/Expect, it would be: > spawn passwd [lindex $argv 0] > set password [lindex $argv 1] > expect "password:" > send "$password\r" > expect "password:" > send "$password\r" > expect eof > > > How would I do it in ExpectPerl??? Couple of things, I'm pretty sure that someone has solved this problem already and that at least one good solution exists. But if you want to write one yourself that's great. If you want someone else to write one for you then you might find that an existing solution will get you going faster than reinventing the wheel. If you're still committed to doing it yourself, write some perl, using Expect.pm if you'd like, and then show us what you've come up with. The best way to learn is to look at example expect code. Some comes with the Expect.pm module and if you look in the archives for this list you'll find some too. |