Why does set also change setenv variables?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Why does set also change setenv variables?
# 1  
Old 11-21-2008
Why does set also change setenv variables?

I thought that set and setenv was easy enough to understand until I started experimenting.
I noticed the same problem in a previous thread, so I will use it as an example.

set command gave the following output:

argv ()
cwd /homes/e/ee325328/assignment.2
home /homes/e/ee325328
path ( a whole bunch of paths)
prompt sol%
shell /bin/csh
status 0
term ansi
user ee325328

setenv command gave the following output:

HOME=/homes/e/ee325328
PATH=bla bla
LOGNAME=ee325328
_INIT_PREV_LEVEL=S
_INIT_RUN_LEVEL=3
_INIT_RUN_NPREV=0
_INIT_UTS_ISA=sparc
_INIT_UTS_MACHINE=sun4d
_INIT_UTS_NODENAME=sol
_INIT_UTS_PLATFORM=SUNW, SPARCserver-1000
_INIT_UTS_RELEASE=5.7
_INIT_UTS_SYSNAME=SunOS
_INIT_UTS_VERSION=Generic_106541-19
PWD=/homes/e/ee325328/assignment.2
USER=ee325328
OPENWINHOME=/usr/openwin

The following variables are common to both:
HOME
PATH
USER
(but they are lower case for set and uppercase for setenv)
When using the set command to change any of these, the setenv values are also affected, and vice versa.

How is a variable common to the shell and the environment created?

I tried creating a shell variable and an environment variable of the same name, but their values can be changed independently.
Which leads to another question: If the value is different, which one takes precidence?
Better stop and try and undertand what's going on before going any further.
# 2  
Old 11-23-2008
The linkages between the 3 variables you mention were created by the author of csh at the time it was written. They are goofy and inexplicable. Please consider switching to ksh or bash. Their features make more sense.
# 3  
Old 11-24-2008
BTW, there are 4 linked variables on most versions of csh. The 4th is 'term'
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Set, setenv or export? Confused between three options

Hi Experts, Need your help in understanding the commands to setup the environment variables in hp-ux. Beleive need to use either set,setenv or export. I am confused between above three options, when to use which option? On command line, I have tried both set and setenv but couldn't... (7 Replies)
Discussion started by: userexperience
7 Replies

2. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

3. Shell Programming and Scripting

Perl Csh - setenv ENV change environment variable

I have 3 programs, 1 in perl, 2 in csh: call them perl1, csh1 and run.ol I need perl1 to set csh1 variable NOLOG_qsub = "" I need perl1 to run, run.ol run.ol takes the executable and input and outputs to output run.ol#!/bin/csh -f # run.ol executable input output perl1 should... (1 Reply)
Discussion started by: austinj
1 Replies

4. Shell Programming and Scripting

Need to SET Environment variables

Hi Could you please tell me how to set environment variables in Unix ksh. And how can acess those varibles in shell scripts ( Please give the code with an example) For my scenario. We have written number of shell scripts with hard coded username and password. But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies

5. AIX

How to set permanent variables

I set my TERM variable to work with SMIT and everything works fine but when I logged out and log in again I have to set the variable again. How can I set a permanent variable into the system so it will be as I wish even if a reboot is needed? I set variables this way: export VAR=value (7 Replies)
Discussion started by: agasamapetilon
7 Replies

6. UNIX for Dummies Questions & Answers

Using Variables to Set Other Variables

I have a script that I'm trying to shorten (below) by removing repetitive code. if ] then commodity_ndm_done=Y fi if ] then customer_ndm_done=Y fi if ] then department_ndm_done=Y fi if ] then division_ndm_done=Y fi (3 Replies)
Discussion started by: superdelic
3 Replies

7. UNIX for Dummies Questions & Answers

Difference between SET and SETENV

I never undestood exactly what's the difference between the SET and SETENV commands. One sets variables visible to all users and the other (SETENV) only to the specific user environment ? Thanks in advance, BraZil - thE heLL iS HEre :mad: !!! (2 Replies)
Discussion started by: 435 Gavea
2 Replies

8. UNIX for Dummies Questions & Answers

how to set up linux environment variables?

Hi I'm using Linux, in the directory /root/my there is a.out. but when I try to run it , the shell indicate "bash:a.out: command not found" but I AM working in this directory. if I use "./a.out" , it works perfectly. can any body tell me how to do a permanent set up so that I can use... (5 Replies)
Discussion started by: dell9
5 Replies

9. Shell Programming and Scripting

How do I set permanent setenv !!!

Hello, I just want to know ow I can set permanent pathes or whatever using setenv command. I'm using c shell . regards, me (1 Reply)
Discussion started by: geoquest
1 Replies

10. UNIX for Dummies Questions & Answers

set, setenv

Well first of all I am a real Unix newbie. I am taking a course on it in University. I kind of understand set and setenv but, I think it si something that I should really understand. So I thought that I would try a forum out and see how good you guys really are. The question: Execute the... (1 Reply)
Discussion started by: w6u6f
1 Replies
Login or Register to Ask a Question