[Semibug] Late reply - Setting environment variables {SOLVED}

David Billsbrough orlandobsd at riseup.net
Sat Aug 12 17:53:36 EDT 2023


Previous posted by Mark Moellering <mark...g at psyber...>

> I figured out I could put them in the csh.cshrc file, which put them in
> the root environment, which is all I needed, as root will call
> dehydrated via a cronjob.

> I just had to put them in csh format instead of sh format.


Mark and all,

If there is just a few (ENV) varibles to set for the script to
run correctly I would set them at the top of the script that needs to
use them.

Later then you trying to figure out where/why they are set it should be
noted in the notes (micro_docs :-) ) in the very script (for
readiblilty)

Whatever you cleverly write/program today can easily kick you in the
teeth as soon as six months later.

I think that most cron jobs run as root and therefore inherit 'root' env
variables.

Example:
--------

#!/bin/bash

# $Id: daycounts,v 0.3 2006/07/18 11:21:00 kc4zvw Exp kc4zvw $

MAILER=/usr/bin/mailx
SUBJECT="Current count down to this year's schedule"
MAILCC=user2 at example.net
MAILTO=user1 at example.net

export TZ=EST5EDT

echo
echo "Schedule of events for this year."
echo

/usr/local/bin/daystogo.rb | ${MAILER} -s "$SUBJECT" "$MAILTO" "$MAILCC"

echo Mail sent to $MAILTO

# End of Script

regards,

David
-- 
David Billsbrough - Chuluota, FL
The almost *BSD developer and hardware hacker
web: https://www.orlandobsd.net/



More information about the Semibug mailing list