LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 05-25-2004, 10:25 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
how do you set an env variable from within a csh script?


I'm creating a job system that will allow users to create a new "job". It essentially makes a whole bunch of directories and creates/modifies a whole bunch of environment variables. The environment variables are determined by user input when they run the script (one of the command line arguments).

If I simply use "setenv FOO BAR", the variable FOO is only set for the duration of the script. How do I make it persist? I've read that I could use the '.' command to launch another file from within my script, but then how would I get the user input to that file?

I'm making a csh script just because I'm more familiar with csh. I suppose I could use bash if this becomes easier in bash.
 
Old 05-25-2004, 10:34 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
It doesn't, though.

Basically shell variables aren't persistent. If you
need that feat. you may have to look into a bit
more of coding and read/write the required values
from/to files, I guess.


Cheers,
Tink
 
Old 05-26-2004, 02:35 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally posted by Tinkster
It doesn't, though.

Basically shell variables aren't persistent. If you
need that feat. you may have to look into a bit
more of coding and read/write the required values
from/to files, I guess.


Cheers,
Tink
but if I setenv in a shell, that shell has that variable set until I close it. Why can't I have a script set the variable for the shell it was launched from?
 
Old 05-26-2004, 03:16 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
man bash
/COMMAND EXECUTION




Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
socks proxy - env variable andrewlkho Linux - Networking 1 06-23-2013 10:58 PM
scp error, TERM env. variable not set? jimbo Linux - Networking 2 11-26-2005 02:31 AM
How to test if an env variable is set King of Men Linux - Newbie 5 11-03-2005 05:39 AM
csh: variable input of the form x.y.z not accepted kpachopoulos Programming 1 07-24-2005 05:39 PM
env variable allelopath Linux - Software 3 04-14-2005 01:07 PM


All times are GMT -5. The time now is 10:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration