The following code worked and is now implemented via a cron job. The problem came about when it was actually waiting for expect to find the text. Instead of waiting for it to find it I knew that it would only take a second or two for it to ask for the password so I just set the timer to 10 seconds and it works. File decrypted successfuly.
# Start the pgp decrypt process.
($decrypt = Expect->spawn("pgp $pgpfile")) || die "Couldn't spawn pgp
+decrypt, $!";
# Wait for 10 seconds then post the password.
sleep(10);
print $decrypt "pass phrase goes here\r";
if(-e $outfile){
$message="$pgpfile decrypted successfully to $outfile.";
} else{
$message="$pgpfile NOT decrypted to $outfile!";
}
sleep(5);
system("mv $pgpfile archive/");
Thanx for the help. |