in reply to Re: Cron, Shell Script, and Perl
in thread Cron, Shell Script, and Perl

Here is the main part of code that is used with expect and where it is unable to actually expect the phrase:
# Start the pgp decrypt process. ($decrypt = Expect->spawn("pgp $pgpfile")) || die "Couldn't spawn pgp +decrypt, $!"; # Check to see for the password prompt. If prompted then post the pas +sword. if($decrypt->expect(30,"Enter pass phrase: ")){ sleep(3); print $decrypt "pass phrase goes here\r"; }

Replies are listed 'Best First'.
Re: Re: Re: Cron, Shell Script, and Perl
by jj808 (Hermit) on Oct 07, 2002 at 16:53 UTC
    Instead of trying to capture the PGP output yourself, have you thought about using one of the PGP modules from the CPAN?

    JJ

      Thanx, I got it fixed using expect and then waiting to post the pass phrase.
Re: Re: Re: Cron, Shell Script, and Perl
by zigdon (Deacon) on Oct 07, 2002 at 16:28 UTC
    My guess is that pgp doesn't want to run without a terminal. I think I've seen it complain about not being able to ask for the passphrase. Isn't there an option in pgp to allow reading the passphrase from a filehandle? That would get around the lack of terminal, and probably get rid of Expect as a byproduct...

    -- Dan

      Hum. I don't believe that pgp will actually allow a person to pull the pass phrase from a file due to security reasons. But I am trying to automate the process and expect is the only way that I have found out how. As I said before the script runs fine as long as I run it manually. what if i just setup a timer to print the pass phrase without expecting something. Something like:
      sleep(10); print "pass phrase goes here\r";
      would something like that work in theory?
        I doubt it. You'll be printing out to the STDOUT of your script, which has little to do with the STDIN of the pgp process, even assuming that it will let you. And I'm guessing that pgp will not even ask the question, as it has no controlling TTY to begin with. I guess there has to be a way to fake one, but I don't know how.

        -- Dan