I have a small problem with expect.pm. I am using expect module to create pgp
keys with my pgp program. The problem is since expect just enters the data with
constant time, pgp cannot doesn't collect enough random data and that's why
cannot create the keys instantly and requires user to enter some random data
from the keyboard. I tried to print some long random text but pgp doesn't get
any of it. I think it requires the random data to be inputted from the
keyboard. Is there any way to do that? Any help would be appreciated. Thanks in
advance.
note to the admin: you can discard my previous email from
ai...@lu.... Thank you.
here is my code:
#!/usr/bin/perl
# deneme.pl -- my first perl script!
use Expect;
#optional debugging
$Expect::Debug=1;
$Expect::Exp_Internal=1;
$Expect::Log_Stdout=0; #on by default
$keytype = 2;
$keysize = 1;
$expire = 0;
$name = 'aziz';
$email = 'chi...@ho...';
$passphrase = 'vasdfasdfi;iejfaekajsdcm,.xzmnaijd;fkdfadjf;kfjajf';
$defaultsignkey = 'n ';
$randomtext =
';asf;j9u9243rk;nfmnamsfdoiajh;dfadjfkadj;fiwu4riow34234lkjaljdfkajdf;23j;rkjakjfkadj;flajj;akdjf;ei';
($pgp = Expect->spawn("pgp -kg")) || die "Couldn't spawn pgp, $!";
unless ($pgp->expect(10,"Choose 1 or 2: ")) {
die "never got algorithm prompt ".$pgp->exp_error()."\n";
}
print $pgp "$keytype\r";
unless ($pgp->expect(10,"Choose 1, 2, or enter desired number of bits: ")) {
die "never got keysize prompt ".$pgp->exp_error()."\n";
}
print $pgp "$keysize\r";
unless ($pgp->expect(10,"Enter a user ID for your public key: ")) {
die "never got user ID prompt ".$pgp->exp_error()."\n";
}
print $pgp "$name <$email>\r";
unless ($pgp->expect(2," (the default is 0): ")) {
die "never got validity period prompt ".$pgp->exp_error()."\n";
}
print $pgp "$expire\r";
unless ($pgp->expect(2,"Enter pass phrase: ")) {
die "never got pass phrase prompt ".$pgp->exp_error()."\n";
}
print $pgp "$passphrase\r";
unless ($pgp->expect(2," pass phrase again:")) {
die "never got second pass phrase prompt ".$pgp->exp_error()."\n";
}
print $pgp "$passphrase\r";
if ($pgp->expect(10," required data ")) {
print $pgp "$randomtext";
print $pgp "$randomtext";
}
unless ($pgp->expect(2," (Y/n) ")) {
die "never got the default signing key prompt".$pgp->exp_error()."\n";
}
print $pgp "$defaultsignkey\r";
|