According to Mike Paradis:
> >Well, verbose doesn't necessarily mean better explained.  The last
> >couple paragraphs suggest a very different story than the first one.
> 
> Yes, I've been having a hard time explaining this one. You did it perfectly as 
>follows.
> 
> >Are you expecting a setting of TMPDIR in a shell script to persist beyond the
> >execution of that script?
> 
> As I think about this, I've always started the dig from the command line in order to 
>get 
> things going. The 'export' directory is set from within the 'rundig' script which is 
>what 
> I've always used. I'm assuming now that since I called up the dig from the command 
>line 
> and then logged off, that even if the 'export' setting was within the 'rundig' file, 
>it 
> was lost when I logged off. 

No, the TMPDIR setting that the rundig script exports is lost when the
rundig script finishes executing.  The export command in the script
only affects the environment of the process running the script, and any
processes the script itself spawns afterward.  Your login shell is a
separate process with its own separate environment.  Even if you run the
rundig script from your login shell, the script is the child process,
and the login shell is the parent process, so your login shell won't
get any changes the script makes to its environment.

Think of it like DNA.  If you somehow changed your DNA, it wouldn't
change your mother's or father's DNA, even though you inherited your
DNA from them.  However, if you change the DNA in your germ line (the
genes in your gametes), then your children will inherit the changes.
The export command is the shell's equivalent of a germ line mutation, as
opposed to non-exported shell variables which are the shell's equivalent
of mutations to non-germ-line DNA.

> Basically, if I understand this, I should be placing my script (which simply copies 
>some 
> updated files and then runs 'rundig') in say cron.daily to get things started. Once 
>the 
> process has started, I could delete the script so that it does not run again. Since 
>the 
> system started the job, then the 'export' setting from within 'rundig' should be set 
>and 
> working.

If you put your script in /etc/cron.daily, then it will run once a day.
If you delete it, then it will no longer run.  The process that runs
the script will only last until the script has completed the commands
it contains.  After that, the process and its environment cease to exist.
There's nothing permanent about it.  If you want your database updated
daily, you need to run the script daily, or have cron run it for you.
There isn't anything that will stick around to perpetually update your
database.

However, if you set your TMPDIR variable correctly in your rundig script,
or in any other script from which you call htdig and htmerge directly,
then htdig and htmerge will have the correct value for TMPDIR when they
run.  (Just make sure the export command occurs before htdig or htmerge
is called in the script - it does no good if it's after.)

Setting TMPDIR in your login shell is only useful if you plan to run
htdig or htmerge directly from your login shell.  If you run them only
from scripts, then just set TMPDIR in these scripts.

> >Or are you expecting a setting of TMPDIR
> >from the command line to persist beyond your current login session?
> >If so, you don't seem to understand the nature of Unix/Linux runtime
> >environments and their associated variables.
> 
> I understand that once I log off, the settings are lost. Anything set during that 
>shell 
> is lost other than a process I may have shelled out.
> 
> >environment variable setting, apart from perhaps the environment
> >that's inherited from the initial system process, "init".  You don't set
> >that. It normally wouldn't make sense to.
> 
> Basically, that's what I've been trying to find out about. When the system boots, 
>there 
> are various things that are set system wide as a basic environment for all users. 
>What I 
> would like to do is set 'export' so that the system sets this at bootup.
> 
> Thanks for all of this help Gilles, tha'ts very helpful.

Just to hopefully clarify further, there's a dimension to environments
in UNIX and Linux that goes beyond environments in DOS.  That's why
there isn't really the equivalent of an AUTOEXEC.BAT in UNIX/Linux.
Some commands are run at boot-time, from various "rc" scripts somewhere
in /etc (it varies from one system to another), but generally that's not
the place to set environment variables, apart from a very few variables
that some boot-time processes need.  Any environment variables set by
these "rc" scripts won't be inherited by your login shell because the
login shell isn't usually a direct descendant of one of these processes.

Most environment variables tend to fall in the area of "user preferences",
and are set at login time rather than at boot time.  Exactly how that's
done again varies from system to system, and from shell to shell, but
generally there are some variables set on a system-wide basis at login
time in /etc/profile, and on a user by user basis in each user's own
.profile file.

Setting TMPDIR on a system-wide basis would probably be a bad idea, as it
may affect programs other than htdig and htmerge, and you may not want
other programs using the same temporary file directory as htdig/htmerge.
That's why setting this in the script that runs htdig/htmerge is probably
best.

-- 
Gilles R. Detillieux              E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

_______________________________________________
htdig-general mailing list <[EMAIL PROTECTED]>
Information: http://lists.sourceforge.net/lists/listinfo/htdig-general
FAQ: http://htdig.sourceforge.net/FAQ.html

Reply via email to