RE: export question



Here is the problem. What you suggest will place the variable in the
environment, but that is what export is supposed to do.

From the man for bash
export [-fn] [name[=word]] ...
export -p
The supplied names are marked for automatic export to the environment of
subsequently executed commands.

Export should allow me to use the variable in other scripts, but it does not
seem to be doing what it does if used in the profile.

That is what I am confused about.

Tony



-----Original Message-----
From: Mike McCarty [mailto:Mike.McCarty@xxxxxxxxxxxxx]
Sent: Saturday, January 06, 2007 9:22 PM
To: debian-user@xxxxxxxxxxxxxxxx
Subject: Re: export question

Tony Heal wrote:
Maybe I am looking for something I should not see, but if 'export' places
a
variable in the environment shouldn't I be able to see it when using the
'set' command. I wrote this small script to test this and nothing shows in
set. I know I am missing something. If I had the same lines into
/etc/profile when I log in I see JAVA_HOME in set.



#!/bin/sh



JAVA_HOME='/usr/java/j2re1.4.2_03'

export JAVA_HOME


It *is* set in the sub-process created when you run the script.
But that exits. If you execute the shell script in your current
shell, then it will work. For that you use the '.' command. Like
this...

$ cat set_java.sh
#!/bin/sh
JAVA_HOME='/usr/java/j2re1.4.2_03'
export JAVA_HOME

$ ./set_java.sh

$ set | grep JAVA

$ . set_java.sh

$ set | grep JAVA

JAVA_HOME=/usr/java/j2re1.4.2_03

$

I added spaces to make it easier to read.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact
listmaster@xxxxxxxxxxxxxxxx


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: user id validation
    ... I have not tried like that but I feel it can be done because the environment ... Rajnikant Jachak | Software Engg | Persistent Systems Limited ... I am just wondering how to validate a user who is using the script?? ... there specific perl command for that? ...
    (perl.beginners)
  • Re: Script export problem in FC3
    ... > I need to modify the PATH environment using a script. ... > If I run the export command in command line I have no problem, ... The child process has the new environment, ...
    (Fedora)
  • Re: rm -r /usr/local by mistake
    ... (i.e. act the _same_ way, for the same invocation, in any environment). ... In the non-interactive language there is *no* "rm' command, ... So in a noninteractive script, ... Do you understand that "would have to specify the 'non-interactive' flag" ...
    (comp.unix.bsd.freebsd.misc)
  • Re: [kinda ot] writing the date into a file when saving it
    ... > i want to self-document source code files when i write them to disk. ... > find where:w is processed and cause it to look for a script to ... > i know about!command. ... To unsubscribe, ...
    (freebsd-questions)
  • Re: Help with system seeming to return too soon...
    ... >>install script. ... > a new process, sets the environment variables in that process, then ... I can on the command line) that I could get around this problem. ...
    (comp.lang.perl.misc)