LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   shell variables (https://www.linuxquestions.org/questions/linux-general-1/shell-variables-795920/)

thehollow89 03-16-2010 10:20 PM

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.

ghostdog74 03-16-2010 10:33 PM

man bash

cj_cheema 03-16-2010 11:07 PM

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.

thehollow89 03-17-2010 12:05 AM

Quote:

Originally Posted by cj_cheema (Post 3901224)
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.

GrapefruiTgirl 03-17-2010 12:12 AM

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

thehollow89 03-17-2010 12:23 AM

Quote:

Originally Posted by GrapefruiTgirl (Post 3901286)
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. :)

GrapefruiTgirl 03-17-2010 12:36 AM

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

konsolebox 03-17-2010 12:46 AM

Quote:

Originally Posted by GrapefruiTgirl (Post 3901286)
... (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]\+"

GrapefruiTgirl 03-17-2010 02:38 PM

Quote:

Originally Posted by konsolebox (Post 3901316)
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.

:)

pixellany 03-17-2010 02:53 PM

Interesting...."env" does not include anything with my IP. I also cannot find it anywhere in /proc. So where IS is stored??

tuxdev 03-17-2010 02:58 PM

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).

pixellany 03-17-2010 03:06 PM

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.

smeezekitty 03-17-2010 03:44 PM

Quote:

Originally Posted by konsolebox (Post 3901316)
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.

konsolebox 03-18-2010 03:17 AM

Yah.. I haven't noticed that until now. :D

chrism01 03-18-2010 04:31 AM

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.


All times are GMT -5. The time now is 07:22 PM.