Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Automate decryption using GnuPGInterface

Reply
Thread Tools

Automate decryption using GnuPGInterface

 
 
George
Guest
Posts: n/a
 
      11-30-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'utputfile} )

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

os.remove(pgpname)

 
Reply With Quote
 
 
 
 
NavyJay
Guest
Posts: n/a
 
      11-30-2005
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
up"?

 
Reply With Quote
 
 
 
 
George
Guest
Posts: n/a
 
      11-30-2005
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
with:
23 12 * * * /usr/local/bin/decrypt_test.py >
/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/decrypt_certegy.py", line 18, in ?
attach_fhs={'stdin':inputfile,'stdout'utputfile} )
File "/usr/local/lib/python2.2/site-packages/GnuPGInterface.py", line
357, in run
create_fhs, attach_fhs)
File "/usr/local/lib/python2.2/site-packages/GnuPGInterface.py", line
401, in _attach_fork_exec
if process.pid == 0: self._as_child(process, gnupg_commands, args)
File "/usr/local/lib/python2.2/site-packages/GnuPGInterface.py", line
442, in _as_child
os.execvp( command[0], command )
File "/usr/local/lib/python2.2/os.py", line 298, in execvp
_execvpe(file, args)
File "/usr/local/lib/python2.2/os.py", line 352, in _execvpe
raise exc, arg
OSError: [Errno 2] No such file or directory
/home/ns1/PTAccountTransfer.051130022347.pgp
Traceback (most recent call last):
File "/SHCD/scripts/decrypt_certegy.py", line 20, in ?
process.wait() # cleanup
File "/usr/local/lib/python2.2/site-packages/GnuPGInterface.py", line
639, in wait
raise IOError, "GnuPG exited non-zero, with code %d" % (e <<
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
it.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
incorrect decryption using AES/CBC jimgardener Java 2 06-20-2008 03:43 PM
Using hybrid encryption/decryption Susanne Kaufmann Java 1 04-19-2007 10:23 AM
tarfile+bz2 and GnuPGInterface Ron Johnson Python 0 10-17-2004 12:08 AM
encryption and decryption using SoapExtension Henrik Bruhn ASP .Net Web Services 0 02-18-2004 11:55 AM
automate file upload using perl [nix] Perl 1 09-07-2003 06:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57