I'm using Crypt::GPG in a script that takes text and files submitted via a web form and generates an encrypted email. If I run the script in a shell, the following statement works and returns encrypted data. But when called as a CGI, it returns 'undef'.
$gpg->encrypt("Some plain text", $recipientID);
I've set the path to the gpg binary, and specified all the options required to ensure the encryption requires no user input (--always-trust --no-permission-warning --home /path/to/keys) and verified this in a shell.

I've tried setting some environment variables (TERM=dumb, SHELL=/bin/sh and LANG=C) early on in my script on the recommendation of a colleague, but it made no difference.

The script has been in active use for a couple of years on a now obsolete RedHat distro, and is being migrated to a current machine so the modules have all seen some updates. I'd rather not make any big changes to my script that are going to require changes at the recipient.


In reply to Module works when run in a shell, but not when run as a CGI by azureblue

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.