LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-01-2005, 04:16 AM   #1
asaba
LQ Newbie
 
Registered: Oct 2004
Location: UK
Posts: 22

Rep: Reputation: 15
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
 
Old 03-01-2005, 04:58 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
To set a variable you must run:
Code:
VARIABLE=value
export VARIABLE
or in one command:
Code:
export VARIABLE=value
 
Old 03-01-2005, 05:02 AM   #3
asaba
LQ Newbie
 
Registered: Oct 2004
Location: UK
Posts: 22

Original Poster
Rep: Reputation: 15
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
 
Old 03-01-2005, 05:07 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 03-02-2005, 02:42 AM   #5
asaba
LQ Newbie
 
Registered: Oct 2004
Location: UK
Posts: 22

Original Poster
Rep: Reputation: 15
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
 
Old 03-02-2005, 04:01 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.

Last edited by druuna; 03-02-2005 at 04:04 AM.
 
Old 03-02-2005, 04:35 AM   #7
asaba
LQ Newbie
 
Registered: Oct 2004
Location: UK
Posts: 22

Original Poster
Rep: Reputation: 15
Smile

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
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux shell implementation for a set of commands syeda tabassum Linux - Software 0 11-03-2004 11:53 AM
implementation of linux shell for a set of commands satishkumar LinuxQuestions.org Member Intro 1 10-09-2004 04:28 PM
What set of bash commands are needed to provide support for rpm? LBendixsen Linux - Newbie 2 04-01-2004 11:43 AM
Setenv IBP Linux - Software 3 12-20-2002 09:05 AM
setenv ???? toxic53 Linux - Networking 1 09-26-2001 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:48 AM.

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
Open Source Consulting | Domain Registration