home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!mcsun!julienas!lri!wacren
- From: wacren@lri.fr (Laurent WACRENIER)
- Subject: Re: Setting enviroment variables in a shell script
- Message-ID: <1993Jan25.003213.3784@lri.fr>
- Keywords: environment variables shell script
- Sender: wacren@lri.fr (Laurent WACRENIER)
- Organization: Laboratoire de Recherche en Informatique
- References: <35774@sales.GBA.NYU.EDU>
- Date: Mon, 25 Jan 1993 00:32:13 GMT
- Lines: 35
-
-
- In article <35774@sales.GBA.NYU.EDU>, elouie@sales.GBA.NYU.EDU (Euge) writes:
- |> How do you set an environment variable in a C-Shell script? I tried
- |> setenv enviroment_variable value, but as soon as the script finishes,
- |> the value of the varialbe is reset to its original value. My guess is
- |> that another "process" is created during the run of the script and
- |> when the script
- |> is done, that process is killed.
- |> Is there a way to set environment variables in a shell script?
- |> Thanks.
-
- The way i know is to use shell script and the eval buildin . For example:
-
- The shell script:
-
- cat >script
- #!/bin/csh
- ...
- setenv VARIABLE VALUE
- ...
- echo setenv VARIABLE $VARIABLE
-
- ^D
-
- when you type
-
- % script
-
- it returns
-
- setenv VARIABLE VALUE
-
- to set the environemnt variable, do
-
- eval `script`
-