LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Setenv / set commands (http://www.linuxquestions.org/questions/linux-software-2/setenv-set-commands-296189/)

asaba 03-01-2005 05:16 AM

Setenv / set commands
 
I'm having problems with the set/setenv of my Linux RedHat 7.3. I know I have to update it, but I need this running asap.
I need them to set some enviromental variables to be used in my programs.
Set and setenv are a shell built-in. Anybody knows what it means?
I have it in Linux Redhat 7.2, but don't find it in 7.3.
Anybody can help me ? How can I find it and put it in 7.3?

Thanks

asaba

bathory 03-01-2005 05:58 AM

To set a variable you must run:
Code:

VARIABLE=value
export VARIABLE

or in one command:
Code:

export VARIABLE=value

asaba 03-01-2005 06:02 AM

I thought I could include them in the .cshrc, as:
setenev something /home/as
set VAR=$something something_else

Does export do the same? Can I include it in the .cshrc file?

Thanks

asaba

druuna 03-01-2005 06:07 AM

Hi,

bathory is correct if you are using bash/ksh. setenv is a csh/tcsh shell buildin, so it depends on the shell you are using.

If you are using (t)csh it's done like this:

Code:

set variable="value"
setenv variable

in one command:
Code:

setenv variable value
A build in is a 'command' that's build into the shell and you cannot (most of the time) find it as a 'normal' program.

asaba 03-02-2005 03:42 AM

Thanks

So, if I was using the .cshrc file for the bash I had in 7.2, but it appears non-existing in 7.3, I guess it means it is a different shell type.
How can I find what type of shell is? And then, what kind of similar to .cshrc file could it be in there?
And/how what commands similar to set/setenv could I find there?

If I use "setenv", it only allows me to set a value or string to a variable. If I want to add to the variable PATH all the paths I want to put, it only allows it with "set", where I can add all the strings I want to.

Too many questions....., any possible reply would be great.

Thanks

asaba

druuna 03-02-2005 05:01 AM

Quote:

So, if I was using the .cshrc file for the bash I had in 7.2, but it appears non-existing in 7.3, I guess it means it is a different shell type.
You cannot use .cshrc when using a bash shell. Every shell type has its own startup files.

To find out which files are used by a shell take a look at the manpage(s). At the bottom (FILES section) the files used are mentioned. Also take a look at the INVOCATION (or Startup and shutdown) section. This describes which files are read when the shell is started in a certain 'mode' (login shell, interactive etc).

To give you an idea which files can be read, using the bash shell as example:

/etc/profile
~/.bash_profile
~/.bashrc
~/.bash_logout
~/.inputrc

Quote:

How can I find what type of shell is?
Take a look at your /etc/passwd file, last field shows the shell that's used. Most distro's use the bash (/bin/bash) as the default shell.

BTW: Do _not_ rely on the SHELL variable setting. If you are in a bash shell (SHELL=/bin/bash) and start a csh shell from this bash shell, the SHELL variable still holds SHELL=/bin/bash ............

Quote:

And then, what kind of similar to .cshrc file could it be in there?
See first part of this reply.

Quote:

And/how what commands similar to set/setenv could I find there?
Take a look at bathory's example for a bash/ksh shell, see my example for a (t)csh shell.

Quote:

If I use "setenv", it only allows me to set a value or string to a variable. If I want to add to the variable PATH all the paths I want to put, it only allows it with "set", where I can add all the strings I want to.
It's probably easier if we know what shell it is you are using before starting with examples.

How shells work and what they can do is an important part of understanding linux/unix. Do read the manpages and other shell related info on the net. There are also some excelent books covering this topic.

If you have any more questions: Just ask ;)

Hope this clears things up a bit.

asaba 03-02-2005 05:35 AM

Thanks a lot

I'm sure I'll have more questions, but I better start looking at all these bash files.

thanks for all your help

asaba:)


All times are GMT -5. The time now is 01:45 PM.