First off, I'm fairly new to perl, so please don't crucify me for bad coding practice, etc.
My problem is as such: I've got a script that takes in data from an html form, dumps a feild to a file, and executes gpg to encrypt it. I can dump to file, but it doesn't seem that the encryption is working... It works if I run the script locally on the machine (even as the nobody user, which apache uses to run the script), but not as the CGI. Any ideas?
#!/usr/bin/perl
$gpgpath = "/usr/bin/gpg";
$gpguser = "xxxxxxxx\@xxxxxxxxx.com";
print "Content-Type: text/html\n";
print "<html>\n<body>\n";
$stdin = <STDIN>;
$stdin =~ s/\+/ /g;
%form = split(/=|&/, $stdin);
$filenum = int(rand 50) + 1;
open(OUTMESSAGE, ">tmpMessages/$filenum");
while (($name, $value) = each %form)
{
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
$form{"$name"} = $value;
}
print OUTMESSAGE $form{'body'};
close OUTMESSAGE;
$gpgcommand = "$gpgpath --batch --always-trust --eatr -a -r $gpguser -
+o tmpMessages/$filenum.enc -e";
print $gpgcommand;
print `$gpgcommand`;
print "</body>\n</html>\n";
when executed, the $gpgcommand is printed out, and works if I cut-and-paste the command into a terminal, but not through the perl script. Is this maybe an apache configuration issue?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.