From owner-freebsd-questions@FreeBSD.ORG Thu Oct 27 00:06:44 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 110F216A420 for ; Thu, 27 Oct 2005 00:06:44 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4401743D5F for ; Thu, 27 Oct 2005 00:06:30 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: from obsecurity.dyndns.org (elvis.mu.org [192.203.228.196]) by elvis.mu.org (Postfix) with ESMTP id A104A1A3C19; Wed, 26 Oct 2005 17:06:30 -0700 (PDT) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 6F1FA511F0; Wed, 26 Oct 2005 20:06:29 -0400 (EDT) Date: Wed, 26 Oct 2005 20:06:28 -0400 From: Kris Kennaway To: Bob Hall , freebsd-questions@freebsd.org Message-ID: <20051027000628.GA68638@xor.obsecurity.org> References: <20051025131352.217826@bob> <20051025184502.GA83689@kongemord.krig.net> <20051025190017.GF63163@xor.obsecurity.org> <20051025231057.GA84395@kongemord.krig.net> <20051026075253.GA90196@xor.obsecurity.org> <20051026152328.GA87755@kongemord.krig.net> <20051026163144.GA49942@xor.obsecurity.org> <20051026235103.GA89193@kongemord.krig.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TB36FDmn/VVEgNH/" Content-Disposition: inline In-Reply-To: <20051026235103.GA89193@kongemord.krig.net> User-Agent: Mutt/1.4.2.1i Cc: Subject: Re: Crontab and GPG? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2005 00:06:44 -0000 --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 26, 2005 at 07:51:03PM -0400, Bob Hall wrote: > On Wed, Oct 26, 2005 at 12:31:44PM -0400, Kris Kennaway wrote: > > On Wed, Oct 26, 2005 at 11:23:29AM -0400, Bob Hall wrote: > > > On Wed, Oct 26, 2005 at 03:52:53AM -0400, Kris Kennaway wrote: > > > > On Tue, Oct 25, 2005 at 07:10:57PM -0400, Bob Hall wrote: > > > > > On Tue, Oct 25, 2005 at 03:00:18PM -0400, Kris Kennaway wrote: > > > > > > On Tue, Oct 25, 2005 at 02:45:02PM -0400, Bob Hall wrote: > > > > > > > On Tue, Oct 25, 2005 at 01:13:52PM -0500, Robert Wall wrote: > > > > > > > > Hello! I'm attempting to run GPG from cron, and it's not w= orking. I can run the script from the command line, and all works perfectl= y. When I try to run it from cron, however, it doesn't work. The crontab = calls this script, called "pgpdecrypt" with the following crontab line: > > > > > > > >=20 > > > > > > > > */1 * * * * root /bin/bash /e= tc/pgpdecrypt > > > > > > > >=20 > > > > > > > > The /bin/bash wasn't originally there; I added it to make s= ure that the script was using the correct shell. Still no luck. Here's th= e script that it calls: > > > > > > > >=20 > > > > > > > > echo >> /etc/pgpdecrypt.logger "PGP Decrypter Starting" > > > > > > >=20 > > > > > > > Take the "/bin/bash" out of your crontab. Put > > > > > > > #!/bin/bash > > > > > > > at the beginning of your script. > > > > > >=20 > > > > > > What do you think that will do to help? It's a NOP, so it can'= t fix > > > > > > the problem (which is because of bad assumptions about PATH, pe= r my > > > > > > other message). > > > > >=20 > > > > > Well, I don't know whether "#!" is a NOP or not. It does tell the= script > > > > > which executable to use in executing the script. > > > >=20 > > > > Yeah, which he was already doing explicitly (see above) ;-) > > >=20 > > > Which is irrelevant. The fact is that if you put the path at the > > > beginning of the script, the script will run the same under cron as it > > > does under the shell you tested it with. If the OP had put "#!/bin/ba= sh" > > > at the beginning of the script when he tested it, he would have been > > > able to debug it without being confused by the fact that it ran under > > > his shell and not under cron. > >=20 > > No, this was because his environment was not as he expected it to be > > when run from cron, as I've explained to you twice. Just making the > > NOP change of adding #!/bin/bash when the script is already being run > > by /bin/bash will not affect the environment. >=20 > I doubt very much that putting the wrong path into the environmental > variables is going to help anything. PATH does not include /usr/local when run from cron, and his script assumes that it does (it calls gpg not /usr/local/bin/gpg). kKris --TB36FDmn/VVEgNH/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDYBoEWry0BWjoQKURAuuoAJ9opEf1LgI+qYq8XlDxHZIaW5T/WgCguRJk PwcOJW0au+KTKx/TVj6gtdE= =N+bi -----END PGP SIGNATURE----- --TB36FDmn/VVEgNH/--