landonc has asked for the wisdom of the Perl Monks concerning the following question:

Help?!?!? I am trying to create an automated process that runs via a shell script scheduled by cron. My perl script is using expect and it isn't able to capture the output to expect something. Although the perl script does run the expect spawn process it is unable to capture the text while in a cron job. It does work if I manually run it but I need it to be ran via the cron job. Any suggestions?

Replies are listed 'Best First'.
Re: Cron, Shell Script, and Perl
by Zaxo (Archbishop) on Oct 07, 2002 at 16:11 UTC

    A cron job does not have a tty or a login environment. You'll need to examine your code for assumptions about those. Are you getting email from cron about errors?

    If you'd like to post code, we can give you a better idea of what may be breaking.

    After Compline,
    Zaxo

      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"; }
        Instead of trying to capture the PGP output yourself, have you thought about using one of the PGP modules from the CPAN?

        JJ

        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