From: <db...@CT...> - 2003-08-07 17:32:15
|
I'd do more error checking than this, but something like this should be a start, and would be a rough minimal equivalent to your Tcl/Expect code. I did not test. You can do a perldoc Expect if you're running into syntax problems and also take a look at more complex examples there. You can find there also documentation on case-like expect format if you are already familiar with Tcl version. use Expect; my $username = shift; my $password = shift; my $exp = Expect->spawn("passwd $username"); $exp->expect(10, "password:"); $exp->send(10, "$password"); $exp->expect(10, "password:"); $exp->send(10, "$password"); $exp->expect(10, 'eof'); "Harter, Douglas" <dh...@st...> To: "Expect Mailing List Perl (E-mail)" Sent by: <exp...@li...> exp...@li...urc cc: eforge.net Subject: [Expectperl-discuss] Perl Expect with passwd 08/06/2003 04:45 PM 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??? . ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |