[Asterisk-Dev] bash export
Schaefer, Mark
Mark.Schaefer at ONSTAR.com
Fri Apr 16 09:49:26 MST 2004
At issue is not the knowledge of bash, but the fact that asterisk is an
executable that is subject to the environment that it is executed in. If
you bring up a "fresh" bash window then you will not necessarily have
LD_ASSUME_KERNEL=2.4.1.
One way to fix this is to modify the /etc/init.d/asterisk script, which is
fine, but does not solve the problem of running the executable in the
foreground, where the variable would not be set. So, there is a legitimate
concern that some people don't seem to understand.
I suggest two possible solutions:
1) Modify /etc/profile with LD_ASSUME_KERNEL=2.4.1; export
LD_ASSUME_KERNEL
2) create a new script to run asterisk
vi start_asterisk
#!/bin/bash
LD_ASSUME_KERNEL=2.4.1; export LD_ASSUME_KERNEL
asterisk "$1"
-----Original Message-----
From: Dermot McGahon [mailto:dermot at dspsrv.com]
Sent: Friday, April 16, 2004 11:07 AM
To: asterisk-dev at lists.digium.com
Subject: [Asterisk-Dev] bash export
> The new question is: suppose "export
> LD_ASSUME_KERNEL=2.4.1" is issued inside the script
> that starts safe_asterisk, if I stop and start Asterisk
> manually, inside a bash session, what happens to this
> variable? Do I have to write a script that always
> includes this variable before I restart asterisk? is it
> better to somehow include this environment variable in
> the C code? How? Sorry for being new to Linux.
From: man bash
export [-fn] [name[=word]] ...
export -p
The supplied names are marked for automatic export to the
envi-
ronment of subsequently executed commands. If the -f
option is
given, the names refer to functions. If no names are
given, or
if the -p option is supplied, a list of all names that
are
exported in this shell is printed. The -n option causes
the
export property to be removed from the named variables.
export
returns an exit status of 0 unless an invalid option is
encoun-
tered, one of the names is not a valid shell variable
name, or
-f is supplied with a name that is not a function.
As with some unix manpages when you're a beginner, this may not be getting
across to you what you need to know, even though what you need to know, is
stated. And there is a lot to get to know. Make an effort, be seen to make
an effort, but most importantly, read carefully and follow any advice you
are given on lists such as this and you should learn quickly.
Forget about C code. It's an environment variable, controlled by shell
built-in commands. It can be set by a C program but irrelevant for what
you need.
To see the current value of the variable, do:
$ echo $LD_ASSUME_KERNEL
If it's not currently set, you need to set it. Any command in a script
can also be typed in directly at the shell. So do:
$ export LD_ASSUME_KERNEL=2.4.1
The export makes sure that this variable is among the variables set up
in any sub-shells of your current shell. Just:
$ LD_ASSUME_KERNEL=2.4.1
will set the variable in your current shell, but to see why this won't
work, do:
$ bash
$ echo LD_ASSUME_KERNEL
It won't be there because it wasn't exported in the parent shell. When
you run certain scripts, with #!/bin/bash at the top of them for example,
you are telling the command interpreter basically to execute these
commands in a new shell. Do:
$ ps aux | grep bash
and you will see that you can have many shells, not just one.
That should get you going. BTW, this is off-topic for this newsgroup so
you'll have to excuse people for rightly telling you so, and I hope people
won't be mad with me for taking five minutes to explain a few basics to
somebody who seems genuine enough even though I realise that also makes me
off-topic!
To see the value of all variables in the current shell, type:
$ set
If it scrolls off the page, try:
$ set | less
One other thing. Change the subject line before posting to something which
explains the, well, subject. You are replying to digest emails which don't
identify the subject sufficiently well.
Dermot.
--
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
More information about the asterisk-dev
mailing list