gpg - failed to create temporary file
Posted on 2008-10-21
I have written a Perl script on CentOS 4.4 to read the contents of a directory and then encrypt the files using gpg. the command is:
gpg -r 'username' --batch --encrypt-files 'filename.ext'
I created the script as root. When I run it interactively from the console, it works just fine. However, if I try to run it from cron or start it from another process (running as root), I receive the following error:
gpg: failed to create temporary file `~/.gnupg/.#lk0x9804868.xxxxxxxxx.31811': No such file or directory
gpg: fatal: ~/.gnupg: can't create directory: No such file or directory
I've echoed the tilde (~) from within the script and it translates to "/root". The directory "/root/.gnupg" does exist and has proper owner permissions.
Any ideas would be appreciated. Thanks.