LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2002, 07:57 PM   #1
albean
Member
 
Registered: Sep 2002
Distribution: fc2
Posts: 113

Rep: Reputation: 15
help for the newbie needed


Guys,

I just got finished installing a program and this was the message that it gave me:


"Note: be sure to set $RSDIR to point to this directory"

Previously I ran this command:

export RSDIR=/bla/bla/bla



but when I try to run

export $RSDIR=/bla/bla/bla

I get: "not a valid identifier" as the message

What does "set $RSDIR to point to this directory" mean? Does it means some environ variable?

Thanks!
 
Old 10-03-2002, 08:19 PM   #2
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 48
The difference is that in the first export, you didn't use a "$". A $ in the
shell has a very specific meaning (dependent on your shell, which appears
to be bash), and when you try to "export $RSDIR", you are trying to
expand an environment variable that isn't set. If you
export RSDIR=/blah/blah/blah,
you'll get what you expect, if /blah/blah/blah is the directory the program
was talking about. . .
 
Old 10-03-2002, 08:29 PM   #3
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
and after that, if you do "echo $RSDIR" you'll get "/blah/blah/blah"
The way I understand it, you use the $ when you are calling the variable
 
Old 10-03-2002, 08:31 PM   #4
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
ps-

you should put "RSDIR=<directory> export RSDIR" in your .bash_profile, or /etc/profile to set it every time you boot up
 
Old 10-03-2002, 11:07 PM   #5
albean
Member
 
Registered: Sep 2002
Distribution: fc2
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by moses
The difference is that in the first export, you didn't use a "$". A $ in the
shell has a very specific meaning (dependent on your shell, which appears
to be bash), and when you try to "export $RSDIR", you are trying to
expand an environment variable that isn't set. If you
export RSDIR=/blah/blah/blah,
you'll get what you expect, if /blah/blah/blah is the directory the program
was talking about. . .
I did “man export” but all I got back under the heading of bash was a long list of what looked like commands for that shell (among them “export”). So I can see why moses figured out I was using bash.

I was wondering:
What is export?
Is it only found in bash?
-and-
what is meant when moses says: “and when you try to "export $RSDIR", you are trying to expand an environment variable”

Also does the $ symbol mean different things in different shells?

Thanks,

AB, the linux newbie.
 
Old 10-03-2002, 11:36 PM   #6
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
I'm not positive, but I think that the $ symbol has this special meaning in bash only. What he means.... when you use the $ in front of the name, it means you are calling that variable. if you haven't set the variable, you can't add more stuff to a non-existant variable.

the words "environment variable" are key to the explanitation of what "export" does. it just means that you export whatever you just declared into the bash environment that you are in. for example, after you do the "export ANYTHING=/usr/src/" then anytime that bash sees $ANYTHING, it will put /usr/src in it's place.

I hope that helps
 
Old 10-04-2002, 12:30 AM   #7
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 48
$ has a special meaning in all shells.
The reason I knew you were using bash is because bash (and sh, but it's
almost never used for interactive stuff) is the only shell that uses "export"
the others have something called "setenv". Which is confusing because
bash uses printenv to show your environment, just like the other shells.

A very stripped down, probably inaccurate in some places explanation:

A shell has a precedence order for its "operators" (think mathematics and
multiplication/addition/parentheses). It turns out that when a $ is in a
bash command, it is near the top of the precedence peking order. This
means that when bash sees a $, it thinks "Oh, this means what is next
is a variable, and I should evaluate that variable before I do anything else".
Since you tried to "export" a variable that was undefined, you received an
error.
What export does is it "exports" the given keyword/variable to the
entire environment (which is actually limited to this particular instance of
the shell).

Yes, you typically call the environment variable with a $VARIABLE.

All shells use the $ as an indication of a variable, though they can use it in
different ways.
try:

tcsh
setenv BLAH /usr/src
echo $BLAH
printenv BLAH

you'll get get /usr/src returned both times. This is because printenv
expects an environment variable, and the shell interprets (expands) the
$BLAH to be a variable and finds that variable in its environment setup.

Now try printenv $BLAH
You get nothing back. Why? This is because $BLAH is expanded to
/usr/src before it's passed to printenv, and there is no environment variable
called "/usr/src", so it returns nothing.

The above turns out to be similar to bash. Let it suffice to say that there
ARE differences in the way variables are handled (among other things)
between the shells, and that there isn't necessarily a best shell. If you
want to learn about shell scripting, O'Reilly has some good books on the
various shells. Hunt around your various 'bin' directories and you'll find
many different shell scripts, read through them, try to make some of your
own, fail, try again, succeed.
 
Old 10-04-2002, 09:45 AM   #8
albean
Member
 
Registered: Sep 2002
Distribution: fc2
Posts: 113

Original Poster
Rep: Reputation: 15
Thanks, adam_boz and moses. That really helped.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
AIX - Newbie help needed! bobmcobob AIX 4 10-22-2004 08:04 AM
help needed by newbie.... houyi99 Linux - Newbie 1 09-22-2003 03:56 AM
The fun of being a newbie... (help needed) abethepunk Linux - Newbie 11 07-21-2003 06:05 PM
Newbie help needed nosebleed Linux - Software 11 03-09-2003 11:41 PM
Newbie : Help with Samba Needed dastrix Linux - Networking 2 02-25-2003 03:39 PM


All times are GMT -5. The time now is 01:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration