Automate decryption using GnuPGInterface

George rb_acm at yahoo.com
Wed Nov 30 12:16:52 EST 2005


Hi,
   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...

#!/usr/local/bin/python

import os, glob, time, GnuPGInterface

gnupg = GnuPGInterface.GnuPG()
gnupg.options.extra_args.append('--no-secmem-warning')
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 = gnupg.run(['--decrypt'],
attach_fhs={'stdin':inputfile,'stdout':outputfile})

	process.wait()	# cleanup
	inputfile.close()
	outputfile.close()

	os.remove(pgpname)




More information about the Python-list mailing list