pipes python cgi and gnupg

B

byte8bits

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))
 
A

alisonken1

On Dec 28 2007, 7:07 pm, (e-mail address removed) wrote:
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))

The last time I checked, "pass" is a reserved word in Python.

Since you are using a reserved word as a variable, maybe that's what's
messing with your output?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top