[Za-pm] Expect module

Stanton Scott sas1 at ananzi.co.za
Mon Aug 4 07:52:56 CDT 2003


Hi All,

Thanks got it working.

On Mon, 04 Aug 2003 11:21:16 +0200
 "Stanton Scott" <sas1 at ananzi.co.za> wrote:
> Hi, 
> 
> Im fairly new to perl. Ive been messing around with the
> expect module trying to get it to work with the UNIX
> passwd
> function. I have unforntunately hit a problem.
> 
> It seems when I try to use the expect function with
> passwd
> it matches the first password entry request and sends the
> correct response to the passwd application. Unfortunately
> on password confirmation it is not always able to match
> the
> request for password confirmation, thus timeing out.
> 
> I have tested this routine using the same user and
> password
> for about 5-10 attempts, each time the percentage of
> requested passed and failed varies. Sometimes the
> requests
> passed out number the request failed and sometimes it is
> the other way around.
> 
> Here is the part of the routine where the expect function
> is used:
> 
> 
> ##set the users unix password
> sub set_user_unix_password {
>   my $passwd_exp=Expect->spawn("passwd", $new_user) or
>        die "error: could not spawn password process\n";
>   $passwd_exp->log_stdout(0);
>   $passwd_exp->debug(0);
> 
>   #user password
>   @passwd_return=$passwd_exp->expect(10, "New
> password:");
>   $passwd_exp->send("$user_password\r\n");
>   # check password
>   printf "*** password section ****\n";
>   printf "match         : $passwd_return[0]\n";
>   printf "why returned  : $passwd_return[1]\n";
>   printf "string matched: $passwd_return[2]\n";
>   printf "before matched: $passwd_return[3]\n";
>   printf "after matched : $passwd_return[4]\n";
> 
> 
>   #confirm password
>   @passwd_return=$passwd_exp->expect(10, "Retype new
> password:");
>   $passwd_exp->send("$user_password\r\n");
>   # check confirmed password
>   printf "*** password confirm section ****\n";
>   printf "match         : $passwd_return[0]\n";
>   printf "why returned  : $passwd_return[1]\n";
>   printf "string matched: $passwd_return[2]\n";
>   printf "before matched: $passwd_return[3]\n";
>   printf "after matched : $passwd_return[4]\n";
> 
>   $passwd_exp->soft_close();
> }
> 
> 
> If anybody could help with this it would be much
> appreciated.
> 
> 
> Thanks,
> Stanton.
>  
> ==
> Download ringtones, logos and picture messages at Ananzi
> Mobile Fun.
> http://www.ananzi.co.za/cgi-bin/goto.pl?mobile
> _______________________________________________
> Za-pm mailing list
> Za-pm at mail.pm.org
> http://mail.pm.org/mailman/listinfo/za-pm

 
==
Download ringtones, logos and picture messages at Ananzi Mobile Fun.
http://www.ananzi.co.za/cgi-bin/goto.pl?mobile



More information about the Za-pm mailing list