[This properly belongs in comp.unix.shell; Follow-up set]
On Thu, 26 Jun 2003 at 22:52 GMT, Arun Goel wrote:
> I am trying to execute a simple shell script to set the environment
> It runs fine without any errors but i doesn't sets the environment
> variables. I don't know what is wrong with the shell script.
A script (or any other program) cannot change the environment of
its parent process. However, there is a method, called sourcing,
which allows a script to be run as part of the calling process.
The syntax is: ". /path/to/script", e.g.;
If it's in your PATH, you can just do:
> I am using korn shell.
> One more thing, is there anyway that same shell scripts can be run in
> Bourne,C , Korn shell without any modification. I mean to say that we don't
> have have to change the way they set different environment variables.
There are two basic types of shell, Bourne (sh, ksh, bash, et al)
and C (csh, tcsh); with very few exceptions, scripts written for
one type will not run in the other. Scripting in csh is not
recommended. See these documents for reasons:
Scripts written for a Bourne shell will (with a few gotchas) run
in any other Bourne-type shell.
Chris F.A. Johnson http://cfaj.freeshell.org
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License