gpg script in cron failed with "stdin must be a tty"
Johan Parin
Johan.Parin@abc.se
Fri Aug 8 08:40:02 2003
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
"Mike" =3D=3D Mike Hsu <mhsu@nglm.com> writes:
Mike> A simple gpg script with no passphrase needed:
Mike> gpg --output junk.txt --decrypt junk2.gpg
Mike> runs OK in bash but fails in cron job.
Mike> I get the following message in mail:
Mike> stdin must be a tty
Mike> How can I fix this?
On my Debian system, the following script runs without any problems
=2D From cron:
#!/bin/sh
export GNUPGHOME=3D/data/gnupg
gpg --no-default-keyring --secret-keyring testsec.gpg \
--keyring testpub.gpg --output testfil.txt --decrypt \
testfil.gpg=20
The thing to remember about cron is that the jobs are run in a very
minimal environment, for instance on my system PATH is set to
"/usr/bin:/bin". And no .profile, .bashrc etc is run. So if your gpg
usage is depending on *any* environment settings whatsoever, you need to
set them manually in the cron job.
=2D --=20
Johan Parin <Johan.Parin@abc.se>
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: http://www.abc.se/~m8897/keys.asc
iD8DBQE/M0YVBXDEkJspWLARAlnUAKCFcYxH5rwcNNjxZdGdUdL70ogBQwCeJqhf
a8WkRNm7+NX7yMA3fxyhh3o=3D
=3DyW3r
=2D----END PGP SIGNATURE-----