* export variables
@ 2003-01-24 7:47 ramzez
2003-01-24 13:59 ` Jude DaShiell
2003-01-24 17:37 ` Steven Smith
0 siblings, 2 replies; 3+ messages in thread
From: ramzez @ 2003-01-24 7:47 UTC (permalink / raw)
To: linux-newbie
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi friends...
I have a trouble when try to export variables... I write a script like this:
- -------------- test.sh ------------------
export MY_VAR="SOME_VALUE"
echo "$MY_VAR"
- -------------- test.sh ------------------
later: chmod +x test.sh then run this script: ./test.sh ... everything looks
OK :)
but when try to use this variable in my environment I can't do, if write
"env" the nev variable MY_VAR doesn't appear ... I think that there are some
protection about export variables, but how do I can export variables?
I'm using red hat 7.3
thanks
- --
Linux User Registered #232544
my GnuPG-key at www.keyserver.net
--- rm -rf /bin/laden ---
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+MO+xs4dF9gl05swRApKYAJ0TmE/LvroRvx9BFMgYxZkHP9vNnACeKYkH
PbQvNbrsquCZ0dSrEJXxsC4=
=EQRI
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: export variables
2003-01-24 7:47 export variables ramzez
@ 2003-01-24 13:59 ` Jude DaShiell
2003-01-24 17:37 ` Steven Smith
1 sibling, 0 replies; 3+ messages in thread
From: Jude DaShiell @ 2003-01-24 13:59 UTC (permalink / raw)
To: ramzez; +Cc: linux-newbie
use the ($) just in front of the variable when testing it in an if
statement or trying to echo its value.
--
Jude <dashielljt(at)gmpexpress-dot-net>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: export variables
2003-01-24 7:47 export variables ramzez
2003-01-24 13:59 ` Jude DaShiell
@ 2003-01-24 17:37 ` Steven Smith
1 sibling, 0 replies; 3+ messages in thread
From: Steven Smith @ 2003-01-24 17:37 UTC (permalink / raw)
To: ramzez; +Cc: linux-newbie
[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]
> - -------------- test.sh ------------------
> export MY_VAR="SOME_VALUE"
> echo "$MY_VAR"
> - -------------- test.sh ------------------
> later: chmod +x test.sh then run this script: ./test.sh
>
> but when try to use this variable in my environment I can't do, if write
> "env" the nev variable MY_VAR doesn't appear ... I think that there are some
> protection about export variables, but how do I can export variables?
The environment of a process cannot easily be changed from outside
that process once the process has started running. This means that
exporting a variable does not do the obvious thing: if you run
a shell script, which tries to export a variable, then that variable
will only be exported to processes which are spawned by that shell
script. In particular, if test.sh contains
export WIDGET=wobble
then running test.sh will have absolutely no effect on the environment
of the shell which invoked it.
If you need to change a running shell's environment through a script,
then you need to get that shell to source rather the script rather
than to execute it. To do this, go
$ . ./test.sh
This causes the shell to run test.sh as if it had been typed in at
the command line, rather than spawning an entirely independent shell
and running test.sh through that.
Steven Smith,
sos22@cam.ac.uk.
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-01-24 17:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-24 7:47 export variables ramzez
2003-01-24 13:59 ` Jude DaShiell
2003-01-24 17:37 ` Steven Smith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox