byte8bits
12/29/2007 3:08:00 AM
I think this is more a GnuPG issue than a Python issue, but I wanted
to post it here as well in case others could offer suggestions:
I can do this from a python cgi script from a browser:
os.system("gpg --version > gpg.out")
However, I cannot do this from a browser:
os.system("echo %s | gpg --batch --password-fd 0 -d %s > d.out"
%(pass, filename))
The output file is produced, but it's zero byte. I want the decrypted
file's content, but the pipe seems to mess things up. The script works
fine when executed from command line. The output file is produced as
expected. When executed by a browser, it does not work as expected...
only produces a zero byte output file. Any tips? I've googled a bit
and experimented for a few nights, still no go.
Thanks,
Brad
Here's the entire script:
#!/usr/local/bin/python
import cgi
import cgitb; cgitb.enable()
import os
import tempfile
print "Content-Type: text/html"
print
print "<TITLE>T</TITLE>"
print "<H1>H</H1>"
form = cgi.FieldStorage()
if not form.has_key("pass"):
print "Enter password"
filename = "test.gpg"
pass = form.getvalue("pass").strip()
os.system("gpg --version > gpg.out")
os.system("echo %s | gpg --batch --password-fd 0 --decrypt %s > d.out"
%(pass,filename))