By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,677 Members | 1,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,677 IT Pros & Developers. It's quick & easy.

Automate decryption using GnuPGInterface

P: n/a
Does anyone have any experience with GnuPGInterface? I'm having a
problem with decrypting files through a cron job. The below job works
great when I run it manually from the command line, but it blows up
whenever I try to run it through cron, and I can't really figure out
why. I've been trying to learn python, and I'm at the point where I can
get things working in small scripts (you know, just enough to be
dangerous). If anybody could shed some light as to what I might be
doing wrong, I would really appreciate it. TIA...


import os, glob, time, GnuPGInterface

gnupg = GnuPGInterface.GnuPG()
gnupg.passphrase = ######

# get list of files in /home/ns1
# that match regex pattern
for pgpname in glob.glob("/home/ns1/[ABDP]*.pgp"):
txtname = pgpname.replace('.pgp','.txt')
inputfile = file(pgpname,'r')
outputfile = file(txtname,'w')

process =['--decrypt'],
attach_fhs={'stdin':inputfile,'stdout':outputfile} )

process.wait() # cleanup


Nov 30 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Are you able to run a dummy Python script using crontabs? For
troubleshooting purposes, I would verify this before trying to debug my
code. Check your permissions, paths, etc.

Can you post your entry into cron? What exactly happens when it "blows

Nov 30 '05 #2

P: n/a
I have 5 python scripts I've added to cron over the past year that run
correctly all the time. I double-checked the permissions and paths and
everything looks good there. Here's the cron entry that I just tested
23 12 * * * /usr/local/bin/ >
/usr/local/bin/decrypt.log 2>&1

As for "blowing up", I get the typical stack trace, but I'm not
python-savvy enough to quite figure it out:

Traceback (most recent call last):
File "/SHCD/scripts/", line 18, in ?
attach_fhs={'stdin':inputfile,'stdout':outputfile} )
File "/usr/local/lib/python2.2/site-packages/", line
357, in run
create_fhs, attach_fhs)
File "/usr/local/lib/python2.2/site-packages/", line
401, in _attach_fork_exec
if == 0: self._as_child(process, gnupg_commands, args)
File "/usr/local/lib/python2.2/site-packages/", line
442, in _as_child
os.execvp( command[0], command )
File "/usr/local/lib/python2.2/", line 298, in execvp
_execvpe(file, args)
File "/usr/local/lib/python2.2/", line 352, in _execvpe
raise exc, arg
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "/SHCD/scripts/", line 20, in ?
process.wait() # cleanup
File "/usr/local/lib/python2.2/site-packages/", line
639, in wait
raise IOError, "GnuPG exited non-zero, with code %d" % (e << 8)
IOError: GnuPG exited non-zero, with code 65536
I'm guessing it has something to do with stdin, stdout, and cron, but I
can't figure out any more than that, or how I would go about changing

Nov 30 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.