Setting Env

Jerry McAllister jerrymc at msu.edu
Wed Mar 7 16:38:33 UTC 2007


On Wed, Mar 07, 2007 at 08:08:35AM -0800, Drew Jenkins wrote:

> >> ----- Original Message ----
> >> From: Jerry McAllister <jerrymc at msu.edu>
> >> To: Drew Jenkins <drewjenkinsjr at yahoo.com>
> >> Cc: freebsd-questions at freebsd.org
> >> Sent: Tuesday, March 6, 2007 7:46:26 PM
> >> Subject: Re: Setting Env
> >>
> >> >If you want the environment variable to
> >> >be set for something that is taking place in the script, then
> >> >that variable must either be set in a durable way in the parent
> >> >environment or be set right there in the script that is using it.
> >> >The rc.conf method will make it available from the parent.
> >> >That is the whole point of rc.conf.
> >>
> >> Right. I figured that much. So, what do I actually put in that file? I
> >> tried these two options:
> >>
> >> setenv LD_LIBRARY_PATH /usr/local/lib/mysql/
> >>
> >> export LD_LIBRARY_PATH="/usr/local/lib/mysql/"
> >>
> >
> >Well, setenv is a csh or tcsh command and isn't in sh and probably
> >not in bash either (I haven't used bash).
> >
> 
> I am aware of that. I was trying to explain how I used every_possible_combination of things I could think of!
> 
> >The export command is an sh and probably bash command and it
> >doesn't exist in csh or tcsh.
> >
> 
> Yes, yes. I know.
> 
> >
> >>
> >> It didn't like either, presumably because it's not calling a bash or c-shell.
> >> So, what should I put in /etc/rc.conf that will achieve my objective?
> >
> >Look at other variable setting in rc.conf.  That should give you
> >a good clue.   For example, in my rc.conf I have several.  One is:
> >  moused_enable="YES"
> >That makes the moused_enable variable have a value of YES.
> >So, if you want LD_LIBRARY_PATH to have the value of /usr/local/lib/mysql/
> >might that not be:
> >  LD_LIBRARY_PATH="/usr/local/lib/mysql/"
> >
> 
> I tried that and posted yesterday that that failed.

Did you source the rc.conf files?

I am used to using csh/tcsh which uses the source command.  I 
am not sure I remember it for sh, but it might be just '.' followed
by the file name.

Sourcing the file sucks it in and makes all the variable settings
available to the current shell.    You need to do some handbook and
shell documentation reading and example studying.   There are lots
of things on the system that do this and that make good examples
to emulate.    I am not a shell programmer per se, but I manage to
get by through grabbing chunks of things that already work on the
system ad modifying they for my current use.   I think many people
learn that way.

> 
> >If you put it in the script that starts things - there needs to be one -
> >then it depends on the script language, csh/tcsh sh/bash.
> >csh/tcsh use setenv and set
> >sh [and bash] use set  and variable_name=value and needs an export to
> >make it available to other entities besides the shell itself.
> >You should look up the man pages on these things and take a look
> >at some other scripts such as those in /usr/local/etc/rc.d for
> >examples.
> 
> What *things*? As far as scripts, this *should* be easy...

Things like setenv, set, source and such.   rc.d startup scripts, rc.conf.

What does your rc.conf look like?
Boot up with it and then take a look at the values.
make a startup script for whatever it is - probably the install
already put one in /usr/local/etc/rc.d/  
and in that startup script, source the /etc/rc.conf file.

> 
> #!/bin/csh
> setenv LD_LIBRARY_PATH /usr/local/lib/mysql/
> 
> ...right? It doesn't work. Any other ideas?
> Drew
> 
> 
> 
>  
> ____________________________________________________________________________________
> Never miss an email again!
> Yahoo! Toolbar alerts you the instant new Mail arrives.
> http://tools.search.yahoo.com/toolbar/features/mail/
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> 


More information about the freebsd-questions mailing list