LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-16-2010, 10:20 PM   #1
thehollow89
LQ Newbie
 
Registered: Mar 2010
Posts: 14

Rep: Reputation: 0
shell variables


Is there a command or a man page where I could view the shell variables available? I have a test tomorrow and we can use the man pages or built in commands, but not text files. I don't feel like memorizing them.
 
Old 03-16-2010, 10:33 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
man bash
 
Old 03-16-2010, 11:07 PM   #3
cj_cheema
Member
 
Registered: Mar 2006
Location: INDIA
Distribution: RedHat, SuSE, Debian
Posts: 166

Rep: Reputation: 15
Exclamation do man then name of shell!!!

Yes right when u do man <name of shell> say man bash, you will see that shell's available keyword and variables.
 
Old 03-17-2010, 12:05 AM   #4
thehollow89
LQ Newbie
 
Registered: Mar 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by cj_cheema View Post
Yes right when u do man <name of shell> say man bash, you will see that shell's available keyword and variables.
For my homework, I am supposed to use an environment variable to display the ip address of the machine. I can't find the environment variable. Perhaps it isn't listed? I am not sure what to do.
 
Old 03-17-2010, 12:12 AM   #5
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Sounds strange.. At least on my machine, the IP address(s) are not stored in any environment variable that I'm aware of. What have you tried so far to look at the environment variables that ARE configured, and WHERE exactly are you looking, when you say "perhaps it's not listed"?

Also, it's a good practice to tell us what Linux, and which shell (if applicable) you are using. In this particular case, neither of these really matter a great deal, but as a rule, if you're looking for help, let us know what Linux you are running (especially as it seems you are posting from Windows).

Kind regards, and welcome to LQ

Sasha
 
Old 03-17-2010, 12:23 AM   #6
thehollow89
LQ Newbie
 
Registered: Mar 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by GrapefruiTgirl View Post
Sounds strange.. At least on my machine, the IP address(s) are not stored in any environment variable that I'm aware of. What have you tried so far to look at the environment variables that ARE configured, and WHERE exactly are you looking, when you say "perhaps it's not listed"?

Also, it's a good practice to tell us what Linux, and which shell (if applicable) you are using. In this particular case, neither of these really matter a great deal, but as a rule, if you're looking for help, let us know what Linux you are running (especially as it seems you are posting from Windows).

Kind regards, and welcome to LQ

Sasha
I am using CentOS and I am using bash. I checked the man pages for bash environment variables and didn't see anything for IP addresses. I am assuming it is a default one because the assignment has instructions for all the variables we are to set beforehand and this wasn't one of them. Here is the exact question from the assignment:
Using values from Environment Variables only, identify the following?

Your computer’s IP address: _____________________ (Variable Name: ____________________)

This assignment is only for practice for the test, so it isn't crucial. Worst comes down to it, I lose a few marks on the test.

Also thanks.
 
Old 03-17-2010, 12:36 AM   #7
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Hmm.. Well, for your info, check out the man page for the `env` command, just for educational reasons. You will see there a way to use the `env` command to view the currently configured environment, that is, all currently set environment variables.

Maybe CentOS has one set to the current IP.

Sasha
 
Old 03-17-2010, 12:46 AM   #8
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Quote:
Originally Posted by GrapefruiTgirl View Post
... (especially as it seems you are posting from Windows).
I hope it won't offend to ask.. Does this mean that mods can tell what system I'm using? It's ok if you can't answer.

@thehollow89 You can try this command to find a variable.
Code:
set | grep "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"
 
Old 03-17-2010, 02:38 PM   #9
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by konsolebox View Post
I hope it won't offend to ask.. Does this mean that mods can tell what system I'm using? It's ok if you can't answer.
Ehh, it's not a big secret -- I just looked at the little Windows icon in the left pane of your post.

 
Old 03-17-2010, 02:53 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Interesting...."env" does not include anything with my IP. I also cannot find it anywhere in /proc. So where IS is stored??
 
Old 03-17-2010, 02:58 PM   #11
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
Define "IP". There's 127.0.0.1, of course, but your IP is also every single IP between you and the world (this can be a lot of IPs, with NAT around).
 
Old 03-17-2010, 03:06 PM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I meant the IP for my computer--as reported by "ifconfig". This is--I think--unambiguously my address as seen from outside my box. Obviously, if I'm on a router, someone on the other end will see something else.
 
Old 03-17-2010, 03:44 PM   #13
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by konsolebox View Post
I hope it won't offend to ask.. Does this mean that mods can tell what system I'm using? It's ok if you can't answer.

@thehollow89 You can try this command to find a variable.
Code:
set | grep "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"
I am sorry but that is too funny.
Look on the left bottom corner on any post.
 
Old 03-18-2010, 03:17 AM   #14
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Yah.. I haven't noticed that until now.
 
Old 03-18-2010, 04:31 AM   #15
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.3
Posts: 17,548

Rep: Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423
Well, I ran 'set' and 'env' on my system (Centos 5.4) and it's definitely not there. I can only imagine that the test machine will have it set specifically and you'll see it with one of those cmds.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help - combining variables in shell vegas35 Programming 2 10-29-2007 09:28 PM
Shell variables Milosevic Linux - Newbie 2 12-10-2005 10:32 PM
Why?? can not use variables with shell script Bassam Linux - General 9 01-27-2004 07:42 AM
Shell Variables. ducka Programming 5 09-03-2003 05:38 PM
Makefiles and shell variables Snabber Linux - Software 1 08-05-2003 11:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:17 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