jblock
12-12-2003, 10:55 PM
Help! This block of code encrypts some text and sends it to me by email. It runs fine from the command line when I type:
perl myscript.pl
But when I embed it in a cgi script and call it from a web form it does not run. I don't get a syntax error, I just do not get the mail. I don't think it's an environmental problem. My script sets all the required environment variables and paths, so the cgi knows where my encryption key is, where pgp is, where sendmail is, etc.
Any ideas?
use IPC::Open2;
sub encrypt_order {
# Set up the pgp command
$pgpcmd = $pgpprog . " -efa +force \'$pgpuserid\'";
# Open the PGP program for bidirectional I/O
open2(\*READPGP, \*WRITEPGP, $pgpcmd) || die "Can't open PGP: $!\n";
# Send text to be encrypted to PGP
print WRITEPGP $unencrypted;
# Encrypt the data
close(WRITEPGP);
# Get the encrypted data from PGP
@encrypted = <READPGP>;
$encrypted = join ('', @encrypted);
close(READPGP);
}
sub send_order {
# Open The Mail Program
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog: $!\n";
# Standard headers
print MAIL "From: Administrator \<admin@mysite.com\>\n";
print MAIL "To: $recipient\n";
print MAIL "Subject: In-Line Encryption Test\n\n";
print MAIL $encrypted;
close (MAIL);
}
perl myscript.pl
But when I embed it in a cgi script and call it from a web form it does not run. I don't get a syntax error, I just do not get the mail. I don't think it's an environmental problem. My script sets all the required environment variables and paths, so the cgi knows where my encryption key is, where pgp is, where sendmail is, etc.
Any ideas?
use IPC::Open2;
sub encrypt_order {
# Set up the pgp command
$pgpcmd = $pgpprog . " -efa +force \'$pgpuserid\'";
# Open the PGP program for bidirectional I/O
open2(\*READPGP, \*WRITEPGP, $pgpcmd) || die "Can't open PGP: $!\n";
# Send text to be encrypted to PGP
print WRITEPGP $unencrypted;
# Encrypt the data
close(WRITEPGP);
# Get the encrypted data from PGP
@encrypted = <READPGP>;
$encrypted = join ('', @encrypted);
close(READPGP);
}
sub send_order {
# Open The Mail Program
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog: $!\n";
# Standard headers
print MAIL "From: Administrator \<admin@mysite.com\>\n";
print MAIL "To: $recipient\n";
print MAIL "Subject: In-Line Encryption Test\n\n";
print MAIL $encrypted;
close (MAIL);
}