[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

pipes python cgi and gnupg

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))
1 Answer

alisonken1

1/9/2008 5:29:00 AM

0

On Dec 28 2007, 7:07 pm, byte8b...@gmail.com wrote:
<snip>
> 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?