Like others who have posted here it seems, I was having no end of trouble getting PGP to encrypt text submitted via a form. I could do it from the command line, no problem, but never via a script.
The version of PGP on my server (2.6.2) seems to have a different syntax to the oft quoted Julie Meloni solution:
So
system("/usr/local/bin/pgpe -r '$user_id' -o $crypted -a $plainTxt");
would NOT work, the "-r" wasn't recognised and the encryption would fail.
I tried
system("/usr/local/bin/pgp -ea '$user_id' $plainTxt");
which seems to be the syntax this PGP vers. works with but the user id could not be found on the public key ringUNTIL ..
I set the public key ring (pubring.pgp) and the randseed.bin (both in the pgp directory) to be world readable.
system("/usr/local/bin/pgp -ea '$user_id' $plainTxt");
will now do the business. The encrypted file will be "$plainTxt.asc." It seems kind of obvious now.
I don't know how secure this is but it works mate !!
I hope this helps someone out there.