[Q]: failed to decrypt if run from cron.

Gerik fgerik@pc.jaring.my
Tue Aug 21 05:09:01 2001


hi,
i have a perl script which successfully decrypt a file except when
executed from cron where i would only get a blank file.
i'm using GnuPG::Interface. I'm puzzled of where to fix.
the script is as below.
any input is greatly appreciated.

--------- my perl script, start ---------

#!/usr/local/bin/perl

use IO::Handle;
use IO::File;
use GnuPG::Interface;

$datadir = "/data";
$output_file = "./of";
$input_file = "./if";
$passphrase = "MyPassword";

chdir "$datadir" or die "Can't cd to data dir : $datadir \n";
&decrypt_input_file;

sub decrypt_input_file {

     $input = IO::Handle->new();
     $output = IO::File->new( ">$output_file");
     $errfile = IO::File->new( ">>$TEMP_STDERR");
     $passphrase_fh = IO::Handle->new();

     $handles = GnuPG::Handles->new(stdin=>$input, stdout=>$output,
stderr=>$err
file, passphrase=>$passphrase_fh);
     $handles->options( 'stdout' )->{direct} = 1;
     $handles->options( 'stderr' )->{direct} = 1;

     $gnupg = GnuPG::Interface->new();

     $cipher_file = IO::File->new("<$input_file");
     $pid = $gnupg->decrypt(handles=>$handles);
     print $passphrase_fh $passphrase;
     close $passphrase_fh;

     print $input $_ while <$cipher_file>;

     close $input;
     close $cipher_file;
     close $errfile;

     waitpid $pid, 0;

     close $output;
     return (1);
}