easy question : how to set an environment variable ?

easy question : how to set an environment variable ?

Post by testin.. » Sat, 24 Jul 1999 04:00:00



how do i set a env variable.

when i log in to unix, i always have to type
" cd /var/apache/www/htdocs/nglim "

i want to set a variable to this value and then

i can type cd wwwpath to go to this path.

how can i do that ?

thanks a lot.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

easy question : how to set an environment variable ?

Post by Rainer Temm » Sat, 24 Jul 1999 04:00:00



> how do i set a env variable.
> when i log in to unix, i always have to type
> " cd /var/apache/www/htdocs/nglim "
> i want to set a variable to this value and then
> i can type cd wwwpath to go to this path.
> how can i do that ?

Hi testingit,

Simply place this into your profile ($HOME/.profile)
...
YOURVAR=/var/apache/www/htdocs/nglim ; export YOURVAR
...
later on, you can " cd $YOURVAR "
...
regards Rainer

 
 
 

easy question : how to set an environment variable ?

Post by bmar.. » Sat, 24 Jul 1999 04:00:00



   >how do i set a env variable.
   >when i log in to unix, i always have to type
   >" cd /var/apache/www/htdocs/nglim "
   >i want to set a variable to this value and then
   >i can type cd wwwpath to go to this path.
   >how can i do that ?
   >thanks a lot.
It depends on your shell.  For csh or tcsh, you can add this command to
your .login file:
setenv wwwpath "var/apache/www/htdocs/nglim"
For most other shells, put this in your .profile:
wwwpath="var/apache/www/htdocs/nglim";export wwwpath
In either case, you will have to type
cd $wwwpath
Or you can write an alias or a function to replace "cd $wwwpath" with a single
command, call it "cdw" or whatever you want.

Net-Tamer V 1.08X - Test Drive

 
 
 

easy question : how to set an environment variable ?

Post by Barry Margoli » Sun, 25 Jul 1999 04:00:00



>how do i set a env variable.

>when i log in to unix, i always have to type
>" cd /var/apache/www/htdocs/nglim "

>i want to set a variable to this value and then

>i can type cd wwwpath to go to this path.

>how can i do that ?

What I do is make symlinks to directories like this in my directory, e.g.

ln -s /var/apache/www/htdocs/nglim ~/wwwpath

I also set cdpath:

set cdpath=(. ~)

so that I can cd to these things even when I'm not in my directory.  That
"set" command is a csh/tcsh feature, but I suspect other shells have
something similar.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

easy question : how to set an environment variable ?

Post by Dave Granti » Sun, 25 Jul 1999 04:00:00


On Sat, 24 Jul 1999 01:06:29 GMT, Barry Margolin


> snip

> I also set cdpath:

> set cdpath=(. ~)

> so that I can cd to these things even when I'm not in my directory.  That
> "set" command is a csh/tcsh feature, but I suspect other shells have
> something similar.

In ksh, you can try the following:

CDPATH=.:/var/apache/www/htdocs
export CDPATH

then,
$ cd nglim

will take you directly where you want to go.

cheers,
Dave
+---------------------+---------------+


+---------------------+---------------+

 
 
 

1. Question: Setting Environment Variables in C

How do you set an environment variable from within a C
program that will take effect in the calling environment?

Assume I have a C program called changenv which takes two
arguments: an environment variable name and the new value.

csh> setenv TEST test_value
csh> echo $TEST
test_value
csh> changenv TEST new_test_value
csh> echo $TEST
new_test_value

How do I write this 'changenv' program in C?  Is it possible?

-------------------------------------------------------------
Nathan Doss

NSF Engineering Research Center

2. functions with variable number of arguments

3. Question: How to set environment variables from a c program?

4. Multipoint protocol?

5. Question: How to set environment variables

6. DHCP and name resolving

7. Setting variables in a variable array of null variables

8. Need feedback on the A5200 storage array....

9. Setting environment variables (netscape enterprise server/aix)

10. Setting Shell Environment Variables from Within C Programs

11. Dynamically setting environment variables on apache startup?

12. Setting environment variables from a C program??

13. Setting environment variables like pwd