From owner-freebsd-questions Wed Dec 19 15:30: 7 2001 Delivered-To: freebsd-questions@freebsd.org Received: from teak.adhesivemedia.com (teak.adhesivemedia.com [207.202.159.79]) by hub.freebsd.org (Postfix) with ESMTP id 359EA37B405 for ; Wed, 19 Dec 2001 15:29:59 -0800 (PST) Received: from localhost (philip@localhost) by teak.adhesivemedia.com (8.11.6/8.11.6) with ESMTP id fBJNTvm65365 for ; Wed, 19 Dec 2001 15:29:58 -0800 (PST) (envelope-from philip@adhesivemedia.com) Date: Wed, 19 Dec 2001 15:29:57 -0800 (PST) From: Philip Hallstrom To: freebsd-questions@freebsd.org Subject: How can I set an environment variable for /bin/sh scripts (ie. cron?) Message-ID: <20011219152607.R59071-100000@teak.adhesivemedia.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi - I am going nuts trying to figure out how to set an environment variable that will be accessable to my cron scripts... Part of the problem is that the variable needs to be user-specific (ie. read from say ~/.profile). And I can't change my scripts to source $HOME/.profile either. So... Reading the /bin/sh man page I came across this: -------------------------------------------------------------------------- A login shell first reads commands from the files /etc/profile and then .profile if they exist. If the environment variable ENV is set on entry to a shell, or is set in the .profile of a login shell, the shell then reads commands from the file named in ENV. Therefore, a user should place commands that are to be executed only at login time in the .profile file, and commands that are executed for every shell inside the ENV file. The user can set the ENV variable to some file by placing the following line in the file .profile in the home directory, substituting for .shinit the filename desired: ENV=$HOME/.shinit; export ENV The first non-option argument specified on the command line will be treated as the name of a file from which to read commands (a shell script), and the remaining arguments are set as the positional parameters of the shell ($1, $2, etc). Otherwise, the shell reads commands from its standard input. Unlike older versions of sh the ENV script is only sourced on invocation of interactive shells. This closes a well-known, and sometimes easily exploitable security hole related to poorly thought out ENV scripts. -------------------------------------------------------------------------- That last paragraph seems to say that there isn't any way to do what I want, but I can't believe there isn't any way to do this... Any and all help appreciated! thanks! -philip To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message