Sun Managers;
Thanks ALL for your quick responces. I received replies from list below.
The resounding answer was that it CANNOT be done. Not the way I wanted.
Some suggested that I create a second script and then source this script
after the first one finishes. I had tried this before and this does work.
I used the command "<script_one>; source <script_two>", i.e.,
"set_user_name;source /tmp/set.user_name"
I also placed a remove command in the second script to automatically delete
the sourced script when it is sourced.
Some suggested that I use eval, but that did not work.
From: Dennis Martens <MARTENSD@health.qld.gov.au>
From: Tom Crummey <tom@ee.ucl.ac.uk>
From: Jonathan.Loh@BankAmerica.com
From: Mark Hokkanen <mhokkane@securecomputing.com>
From: "Thornton, Charles (cthornto)" <cthornto@harris.com>
From: John Berninger <jberninger@bbtnet.com>
From: "Marco Greene" <cmgreene@netcom.ca>
From: kcolagio@wc.eso.mc.xerox.com (Kevin Colagio)
From: corraant@filon.ml.com (Antonio Corral - System Administrator-x1401)
From: Erwin Fritz <efritz@glja.com>
From: Igor Schein <igor@txc.com>
From: David Thorburn-Gundlach <david@bae.uga.edu>
From: bbyoung@amoco.com (Brad Young )
From: Joel Lee <joellee@continuus.com>
From: Aleksandar Milivojevic <alex@srce.hr>
From: John Wynstra <john@its.brooklyn.cuny.edu>
From: Stefan Voss <s.voss@terradata.de>
From: parkini@bgep.co.uk
From: Jay Lessert <jayl@lscpdx.latticesemi.com>
----Original Question:
I need to run a script and based on a certain condition I need to set a
permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment
variable OK,
If I source a script with a "setenv" command in it, it sets the environment
variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after the
script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it
exists after the script is finished?
Thanks,
Angel
----------Actual Replies follow;
X-Sender: cherub@lava.net
X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.3 (32)
Date: Thu, 06 Aug 1998 06:45:42 -1000
To: sun-managers@sunmanagers.ececs.uc.edu
From: Angel Ortiz <cherub@lava.net>
Subject: Set a permanent environment variable
Sender: owner-sun-managers@sunmanagers.ececs.uc.edu
Sun Managers;
I need to run a script and based on a certain condition I need to set a
permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment
variable OK,
If I source a script with a "setenv" command in it, it sets the environment
variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after the
script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it
exists after the script is finished?
Thanks,
Angel
Date: Thu, 6 Aug 1998 17:56:08 +0100 (BST)
From: Tom Crummey <tom@ee.ucl.ac.uk>
To: cherub@lava.net
Subject: Re: Set a permanent environment variable
Hello,
I don't think you can. The key is that a script executes in a new shell with
a brand new environment which gets thrown away when the script finishes. I
can't think of a command which will set the parent shell's environment.
When you source a script, it runs the commands in the current shell.
Tom.
----------------------------------------------------------------------------
Tom Crummey, Systems and Network Manager, EMAIL: tom@ee.ucl.ac.uk
Department of Electronic and Electrical Engineering,
University College London, TEL: +44 (0)171 419 3898
Torrington Place, FAX: +44 (0)171 388 9307
London, UK, WC1E 7JE. MOBILE: +44 (0)370 264 543
----------------------------------------------------------------------------
From: Jonathan.Loh@BankAmerica.com
Date: Thu, 06 Aug 1998 09:58:58 -0700
Subject: Re: Set a permanent environment variable
To: Angel Ortiz <cherub@lava.net>
Well the reason it doe this is that for every shell process be it a shell
script or whatever, a process is forked. This new process inherits the
parent shells env variable plus adds any other env variables. When this
process exits then so do the newly created env variables.
I'm not sure of a good way to get around this. But you may want to look at
the comp.unix.questions newsgroup. Maybe their FAQ will have something.
Angel Ortiz <cherub@lava.net>
08/06/98 04:45 PM GMT
________________________________________________________
To: sun-managers@sunmanagers.ececs.uc.edu
cc: (bcc: Jonathan Loh)
Subject: Set a permanent environment variable
Classification: Internal Use Only
Sun Managers;
I need to run a script and based on a certain condition I need to set a
permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment
variable OK,
If I source a script with a "setenv" command in it, it sets the environment
variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after the
script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it
exists after the script is finished?
Thanks,
Angel
X-Mailer: exmh version 2.0.2 2/24/98
To: Angel Ortiz <cherub@lava.net>
Subject: Re: Set a permanent environment variable
Date: Thu, 06 Aug 1998 12:02:20 -0500
From: Mark Hokkanen <mhokkane@securecomputing.com>
You can set the output of your shell script to:
setenv XYZ Christmas
What you can do then is:
eval `script`
Other than that you have to source it.
When you run a shell script it more or less spawns another shell for your
script to run in. The variables get set in that shell so when the script is
done the shell quits. The variables in a child shell do not get set in the
parent shell. Thats why you have to source it or do the eval above to get
those variables set.
> I need to run a script and based on a certain condition I need to set a
> permanent (global) (the the current session) environment variable.
>
> In C-Shell:
>
> If I use "setenv XYZ Christmas" at the prompt, it sets the environment
> variable OK,
> If I source a script with a "setenv" command in it, it sets the environment
> variable OK and remains set after the source'd script is finished.
>
> However, If I execute the script with a "setenv" command in it, after the
> script exits, the effects of the setenv commands are gone.
>
> Any way to set the global environment from within a script so that it
> exists after the script is finished?
>
> Thanks,
>
> Angel
From: "Thornton, Charles (cthornto)" <cthornto@harris.com>
To: 'Angel Ortiz' <cherub@lava.net>
Subject: RE: Set a permanent environment variable
Date: Thu, 6 Aug 1998 13:07:11 -0400
X-Mailer: Internet Mail Service (5.5.1960.3)
Angel,
The problem is that when you run the script you are spaning another c-shell...
the environment variable is set for the shell but altering environment
variables
from parent shells is nearly impossible to do from my experience. I hope
someone
can help from the Sun Managers group.
I'll be watching as I'd like to know.
Ed
-----Original Message-----
From: Angel Ortiz [SMTP:cherub@lava.net]
Sent: Thursday, August 06, 1998 12:46 PM
To: sun-managers@sunmanagers.ececs.uc.edu
Subject: Set a permanent environment variable
Sun Managers;
I need to run a script and based on a certain condition I need to set a
permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment
variable OK,
If I source a script with a "setenv" command in it, it sets the
environment
variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after
the
script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it
exists after the script is finished?
Thanks,
Angel
From: John Berninger <jberninger@bbtnet.com>
To: "'Angel Ortiz'" <cherub@lava.net>
Subject: RE: Set a permanent environment variable
Date: Thu, 6 Aug 1998 13:07:36 -0400
The only way to set an environment variable in a script and have it remain
after the script exists is to source the script, as you're seeing. By
executing the script, the kernel invokes a slave interpreter which actually
sources the script in the slave; when the source finishes executing in the
slave, it exists and doesn't leave anything behind in the parent interp.
By sourcing the script, you force execution of the script to remain in the
parent and not start a 'single-purpose' slave interp, thus any environment
changes you make are preserved when the script exits.
John Berninger
UNIX Systems Administration
Branch Banking and Trust
2501 Wooten Blvd M/S 100-99-08-20
Wilson, NC 27893-0819
Phone: (252)246-3601
Pager: (252)292-0714
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
-----Original Message-----
From: Angel Ortiz [SMTP:cherub@lava.net]
Sent: Thursday, August 06, 1998 12:46 PM
To: sun-managers@sunmanagers.ececs.uc.edu
Subject: Set a permanent environment variable
Sun Managers;
I need to run a script and based on a certain condition I need to set a
permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment
variable OK,
If I source a script with a "setenv" command in it, it sets the environment
variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after the
script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it
exists after the script is finished?
Thanks,
Angel
From: "Marco Greene" <cmgreene@netcom.ca>
To: "Angel Ortiz" <cherub@lava.net>
Subject: Re: Set a permanent environment variable
Date: Thu, 6 Aug 1998 13:11:23 -0700
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
The only way to do that is to source the script.
-----Original Message-----
From: Angel Ortiz <cherub@lava.net>
To: sun-managers@sunmanagers.ececs.uc.edu
<sun-managers@sunmanagers.ececs.uc.edu>
Date: Thursday, August 06, 1998 9:54 AM
Subject: Set a permanent environment variable
Sun Managers;
I need to run a script and based on a certain condition I need to set a
permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment
variable OK,
If I source a script with a "setenv" command in it, it sets the environment
variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after the
script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it
exists after the script is finished?
Thanks,
Angel
From: kcolagio@wc.eso.mc.xerox.com (Kevin Colagio)
Subject: Re: Set a permanent environment variable
To: cherub@lava.net (Angel Ortiz)
Date: Thu, 6 Aug 1998 10:12:47 PDT
X-Mailer: ELM [version 2.4 PL25]
While sniffing dried rose petals, Angel Ortiz said:
->
-> I need to run a script and based on a certain condition I need to set a
-> permanent (global) (the the current session) environment variable.
The only way is to run the script and then exec csh before exiting. That
will keep the current shell variables. If you always need the variable,
you can do it in the /etc/.login file (as an alternative).
Hope that helps.
--Kevin Colagio, Systems Administrator, Webmaster, and perpetual student. kcolagio@wc.eso.mc.xerox.com Personal URL:<http://www.rit.edu/~kdc5072>
Date: Thu, 6 Aug 98 18:50:49 BST From: corraant@filon.ml.com (Antonio Corral - System Administrator-x1401) To: cherub@lava.net Subject: Re: Set a permanent environment variable
Angel,
> Sun Managers; > > I need to run a script and based on a certain condition I need to set a > permanent (global) (the the current session) environment variable. > > In C-Shell: > > If I use "setenv XYZ Christmas" at the prompt, it sets the environment > variable OK, > If I source a script with a "setenv" command in it, it sets the environment > variable OK and remains set after the source'd script is finished. > > However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone. > > Any way to set the global environment from within a script so that it > exists after the script is finished? > > Thanks, > > Angel >
That is IMPOSSIBLE to do. You cant change the global environment within a script (unless, as you point out, you source the code with the setenv command in it).
Regards, Antonio
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Antonio Corral: Merrill Lynch - System Administrator Smail: Ropemaker Place, 25 Ropemaker Street, London, EC2Y 9LY Email: corraant@ml.com telno: 0171 573 1401 (Work) 0467 677404 (Mobile) XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Date: Thu, 06 Aug 1998 11:30:58 -0600 From: Erwin Fritz <efritz@glja.com> Reply-To: efritz@glja.com X-Mailer: Mozilla 4.04 [en] (WinNT; U) To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable
Angel Ortiz wrote:
> If I use "setenv XYZ Christmas" at the prompt, it sets the environment > variable OK,
Right. The 'setenv' command always applies to the current shell. In this case that's your login shell.
> If I source a script with a "setenv" command in it, it sets the environment > variable OK and remains set after the source'd script is finished.
The 'source' command says to run the script in the current shell. So the 'setenv' changes the variable in the current shell's environment.
> However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone.
Normally, when you run a command, it gets its own shell, which is a child of your shell.The child shell inherits the environment of its parent. However, there is no way to change the parent's environment from the child.
For example, your script is named abc. At the login shell, you type 'abc' and hit return. A child shell is spawned, with the parent being your login shell. The child has the same environment as the parent. If, inside 'abc', you do a 'setenv', the child's environment will change.
When the script 'abc' ends, the child shell disappears. That's why your 'setenv' doesn't affect the parent.
When you run 'source abc', you're telling 'abc' to run in the current shell. It won't spawn a child shell. Thus any environment changes you make in the script apply to the current shell.
> Any way to set the global environment from within a script so that it > exists after the script is finished?
You must use 'source'. If you don't want to type 'source abc', just alias 'abc' to 'source abc'.
Erwin Fritz UNIX/NT/LAN/DBA Guy Gilbert Laustsen Jung Associates Ltd. http://www.glja.com
Date: Thu, 6 Aug 1998 14:03:00 -0400 From: Igor Schein <igor@txc.com> To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable Reply-To: igor@txc.com X-Mailer: Mutt 0.93.2i
When you run a script, it starts a sub-shell, which cannot do any changes to parent shell environment.
Igor
Date: Thu, 6 Aug 1998 14:55:46 -0400 (EDT) From: Tim Fritz <tim@cfcg.er.usgs.gov> X-Sender: tim@kazoo To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable
> > However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone. >
The script is starting it's own shell. If you do source script the setenv commands will be set in the shell that ran the source command.
-- Tim Fritz
Date: Thu, 6 Aug 1998 15:03:25 -0400 From: David Thorburn-Gundlach <david@bae.uga.edu> To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable X-Mailer: Mutt 0.88 X-Wedding-Date: 94/01/15-19:30 X-Wedding-Time: 39931 hours of wedded bliss :-) X-Madison-Date: 96/12/13-12:00 X-Madison-Time: 14425 hours of fatherhood :-)
Angel --
When you "execute" a script, it kicks off in a subshell, so the variable never really gets set in the current shell; when you "source" a script, it gets run without spawning off a subshell and so any environment modifications you make hang around.
It sounds like you want to like you want to source your script instead of just run it. In csh, as you've said, the command is "source script". The same thing under sh is ". script" -- although, of course, the script must then be a sh instead of csh script (the way it was intended, if you ask me :-) So, in your script where you want to retain the environment variable, just call your external script with the set command as a source.
Meanwhile, you could just have that script spit out the variable's value or even the line that would set it (either "setenv XYZ Christmas" or "XYZ=Christmas;export Christmas" and then trap that inside your parent script and set or execute it appropriately...
:-D -- David Thorburn-Gundlach * It's easier to fight for one's principles (play) david@bae.uga.edu * than to live up to them. -- fortune cookie (work) david_thorburn-gundlach@groton.pfizer.com Helping out at Pfizer http://www.bae.uga.edu/other/david/
Date: Thu, 6 Aug 1998 14:23:43 -0500 From: bbyoung@amoco.com (Brad Young ) To: cherub@lava.net Subject: Re: Set a permanent environment variable
Source the script with the setenv command.
Brad
Sender: "Louis Hoo" <lhoo@fcicom.com> Date: Thu, 06 Aug 1998 12:31:39 -0700 From: Louis Hoo <lhoo@fcicom.com> X-Mailer: Mozilla 4.05 [en] (X11; I; SunOS 5.6 sun4u) To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable
Angel Ortiz wrote: > I've done this in ksh.
Write the script and run it from the prompt with a . before the name eg.
$ . scriptname
here is a script:
#!/bin/ksh
VARNAME="hello world" export VARNAME
cheers, Louis.
> Sun Managers; > > I need to run a script and based on a certain condition I need to set a > permanent (global) (the the current session) environment variable. > > In C-Shell: > > If I use "setenv XYZ Christmas" at the prompt, it sets the environment > variable OK, > If I source a script with a "setenv" command in it, it sets the environment > variable OK and remains set after the source'd script is finished. > > However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone. > > Any way to set the global environment from within a script so that it > exists after the script is finished? > > Thanks, > > Angel
Date: Thu, 6 Aug 1998 13:33:42 -0700 (PDT) From: Joel Lee <joellee@continuus.com> X-Sender: joellee@newspaper To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable
I don;t see anyway to do this because the process space is destroyed once it has exited. What you can do, however, is to run shell within shell. So you can set the env under program A, then run your main program B inside A (csh -f B), so that your child processes sees the inherited env.
-- Joel Lee
(Opinions expressed here is just mine and no one else, not even my employer.)
Continuus Software Corp. joellee@continuus.com http://www.continuus.com
On Thu, 6 Aug 1998, Angel Ortiz wrote:
> Sun Managers; > > I need to run a script and based on a certain condition I need to set a > permanent (global) (the the current session) environment variable. > > In C-Shell: > > If I use "setenv XYZ Christmas" at the prompt, it sets the environment > variable OK, > If I source a script with a "setenv" command in it, it sets the environment > variable OK and remains set after the source'd script is finished. > > However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone. > > Any way to set the global environment from within a script so that it > exists after the script is finished? > > Thanks, > > Angel >
To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable X-Face: *i)`)}F8-FIJ&YUHyu@\lyhlD$>Azp'@'{QxFQ3L}_/T=h;"!+Y#zo.n'Jr- Ugd^$Gv~5?}r1tLuPk\/sr+sFN+7$oXb[=qY`_E!H>i*Fs?I&>:AMFtCC5i?E X-Url: http://jagor.srce.hr/~alex/ From: Aleksandar Milivojevic <alex@srce.hr> Date: 07 Aug 1998 00:40:13 +0200 Lines: 47 X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald"
X-MIME-Autoconverted: from 8bit to quoted-printable by pc-alex.srce.hr id AAA12488
Nope, you can't do that. Child process can not change environment of it's parent. When you source shell script, it will be executed by your current shell process and because of that environment variables set in shell script will remain. If you execute shell script, your current shell process will first spawn another shell (a child process of your current shell) and your shell script will be then executed by that child process.
If you need to set those global variables once for entire session, you can set them in your .chsrc or .login files (if you use csh or tcsh). csh sources .cshrc every time it is started and .login if it is login shell.
If this is not acceptable solution, than you will need to source shell script instead of running it.
Angel Ortiz (cherub@lava.net) wrote: > Sun Managers; > > I need to run a script and based on a certain condition I need to set a > permanent (global) (the the current session) environment variable. > > In C-Shell: > > If I use "setenv XYZ Christmas" at the prompt, it sets the environment > variable OK, > If I source a script with a "setenv" command in it, it sets the environment > variable OK and remains set after the source'd script is finished. > > However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone. > > Any way to set the global environment from within a script so that it > exists after the script is finished? > > Thanks, > > Angel > >
-- Aleksandar Milivojeviæ | alex@srce.hr | http://jagor.srce.hr/~alex/ Opinions expressed herein are my own. ================================ooooO=Ooooo============================== Real Users never know what they want, but they always know when your program doesn't deliver it.
Date: Fri, 7 Aug 1998 01:29:28 -0400 (EDT) From: John Wynstra <john@its.brooklyn.cuny.edu> To: cherub@lava.net Subject: Re: Set a permanent environment variable
> If I source a script with a "setenv" command in it, it sets the environment > variable OK and remains set after the source'd script is finished.
> However, If I execute the script with a "setenv" command in it, after the > script exits, the effects of the setenv commands are gone.
> Any way to set the global environment from within a script so that it > exists after the script is finished? You have said the answer yourself: "source" (aka/ "dot") the script. This is the only way I know of to do what you want. We have "commands" that are nothing but aliases to ". some_script" at Bklyn College, which are just sugar-coating for users who don't know or wantt to be bothered with details like "sourcing".
-- john l. wynstra e-mail: john@its.brooklyn.cuny.edu
Date: Fri, 7 Aug 1998 08:58:21 +0200 (MET DST) From: Stefan Voss <s.voss@terradata.de> To: cherub@lava.net Subject: Re: Set a permanent environment variable
Angel,
when you execute a script, a new process is created. The environment of the current process will be inherited by it's child process, but can never be passed back form a child process to a parent process. So there is no chance, to do what you want. As a work araound, you could write the value of the variable into a file, which can then be evaluated by the parent process, e.g.:
script:
#!/bin/csh -f commands, commands, commands echo blah > blah.txt
and in the shell, you can type:
> script > setenv BLAH `cat blah.txt`
Stefan
,,, (o o) (o o)
--------------------------------o0Oo-(_)-oO0o---------------------------------
Stefan Voss Phone: # 49 (0) 5139-9908-51 System and Network Administration Fax: # 49 (0) 5139-9908-10 TerraData Geophysical Services GmbH e-mail: s.voss@terradata.de Ehlbeck 15 a D - 30938 Burgwedel, Germany
Date: Fri, 7 Aug 1998 08:58:57 +0100 From: parkini@bgep.co.uk Subject: Re: Set a permanent environment variable To: cherub@lava.net
Angel,
you could try writing a script so it returns the command to setenv the variable, and then use eval i.e create a file called /tmp/fred with the following in it:
------Start #!/bin/csh -f
echo "setenv VARNAME value" ------End
Now in a csh at the command prompt type:
eval `/tmp/fred`
You can now use echo $VARNAME to see that the variable has been set.
Cheers,
Ian Parkin
Date: Fri, 7 Aug 1998 08:34:59 -0700 From: Jay Lessert <jayl@lscpdx.latticesemi.com> To: Angel Ortiz <cherub@lava.net> Subject: Re: Set a permanent environment variable X-Mailer: Mutt 0.89.1
On Thu, Aug 06, 1998 at 06:45:42AM -1000, Angel Ortiz wrote: > > Any way to set the global environment from within a script so that it > exists after the script is finished?
I think this one is in several programming and sysadmin FAQ lists, and the answer is:
No.
It is impossible for a child process to directly change the environment of the parent.
It is, of course, possible for the parent to check the return status of the child (or an output file, etc.) and then change it's *own* environment. That is the way you'll need to approach it.
-- Jay Lessert jay_lessert@latticesemi.com Lattice Semiconductor Corp. (voice)1.503.681.0118 Hillsboro, OR, USA (fax)1.503.693.0540
X-Mailer: Novell GroupWise 4.1 Date: Fri, 07 Aug 1998 09:33:35 +1000 From: Dennis Martens <MARTENSD@health.qld.gov.au> To: cherub@lava.net Subject: Set a permanent environment variable -Reply
setenv will set a value from that particular command level DOWN...cannot set it at a higher (earlier) level.
Instead of setting a variable, you could write the value into a temporary file.
echo "value" > /tmp/variable_file
would this work for you? I have had to do this in the past..
Dennis
>>> Angel Ortiz <cherub@lava.net> 7/August/1998 02:45am >>> Sun Managers;
I need to run a script and based on a certain condition I need to set a permanent (global) (the the current session) environment variable.
In C-Shell:
If I use "setenv XYZ Christmas" at the prompt, it sets the environment variable OK, If I source a script with a "setenv" command in it, it sets the environment variable OK and remains set after the source'd script is finished.
However, If I execute the script with a "setenv" command in it, after the script exits, the effects of the setenv commands are gone.
Any way to set the global environment from within a script so that it exists after the script is finished?
Thanks,
Angel
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:45 CDT