home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / shell / 5493 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.2 KB  |  48 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!mcsun!julienas!lri!wacren
  3. From: wacren@lri.fr (Laurent WACRENIER)
  4. Subject: Re: Setting enviroment variables in a shell script
  5. Message-ID: <1993Jan25.003213.3784@lri.fr>
  6. Keywords: environment variables shell script
  7. Sender: wacren@lri.fr (Laurent WACRENIER)
  8. Organization: Laboratoire de Recherche en Informatique
  9. References:  <35774@sales.GBA.NYU.EDU>
  10. Date: Mon, 25 Jan 1993 00:32:13 GMT
  11. Lines: 35
  12.  
  13.  
  14. In article <35774@sales.GBA.NYU.EDU>, elouie@sales.GBA.NYU.EDU (Euge) writes:
  15. |> How do you set an environment variable in a C-Shell script?  I tried
  16. |> setenv enviroment_variable value, but as soon as the script finishes, 
  17. |> the value of the varialbe is reset to its original value.  My guess is 
  18. |> that another "process" is created during the run of the script and
  19. |> when the script 
  20. |> is done, that process is killed.
  21. |> Is there a way to set environment variables in a shell script? 
  22. |> Thanks.
  23.  
  24. The way i know is to use shell script and the eval buildin . For example:
  25.  
  26. The shell script:
  27.  
  28. cat >script
  29. #!/bin/csh
  30. ...
  31. setenv VARIABLE VALUE
  32. ...
  33. echo setenv VARIABLE $VARIABLE
  34.  
  35. ^D
  36.  
  37. when you type
  38.  
  39.     % script
  40.  
  41. it returns
  42.  
  43.     setenv VARIABLE VALUE
  44.  
  45. to set the environemnt variable, do
  46.  
  47.     eval `script`
  48.