Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > Your Distro > Gentoo Linux Help
Reload this Page no $HOST and $DISPLAY variable?
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Gentoo Linux Help For help and discussion related to Gentoo Linux

Reply
 
Thread Tools Display Modes
Old 04-27-2008   #1 (permalink)
PopyCaste
Just Joined!
 
Join Date: Apr 2008
Posts: 3
no $HOST and $DISPLAY variable?

Hello

I wonder why my $HOST and $DISPLAY environment variables are empty. I downloaded a sample .bashrc and it says when spawning a new shell with 'su':
bash: HOST: unbound variable
bash: HILIT: unbound variable

Do you know what I can do to solve this problem?

Best regards,
Phil
PopyCaste is offline   Reply With Quote
Old 04-28-2008   #2 (permalink)
wildpossum
Just Joined!
 
wildpossum's Avatar
 
Join Date: Apr 2008
Location: Sydney/Australia
Posts: 74
Send a message via Skype™ to wildpossum
If your running as a terminal session outside of X then you would expect that $DISPLAY may not be set. If your doing "echo $DISPLAY" within a Xterm under X then you can and would expect the variable to be set to something like ":0".

You haven't explained if and why this should be a problem!

I suspect, if your just playing around to understand the inner workings of shell variables that your simply forgot to export the variable. i.e.:

~>
~> export HELLO='yes OK'
~> echo $HELLO
yes OK
~>
__________________
Grahame
AMD Phenom(QuadCore), 8GB, 3ware RAID6 1.8TB, HD3850(512MB) ..etc.
wildpossum is offline   Reply With Quote
Old 04-28-2008   #3 (permalink)
PopyCaste
Just Joined!
 
Join Date: Apr 2008
Posts: 3
I want to customize this sample .bashrc file http://tldp.org/LDP/abs/html/sample-bashrc.html. But it doesn't work, because the two mentioned environment variables aren't set by default.

Please have a look on the link above and search for "DISPLAY" in it, for example. The author uses if-clauses to determine, on which system we are, using the DISPLAY-variable, doesn't he?
But as you say, normally the variable is not set by default and as a result, i get one error message on every command i enter on the shell..

My question is, how can I change it? And why this could be a working sample .bashrc-file when obviously the environment variables - that are used - are not initialized by default.
When I export the two variables, they won't be there after rebooting, right?

Best regards!
PopyCaste is offline   Reply With Quote
Old 04-28-2008   #4 (permalink)
i92guboj
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 880
Quote:
Originally Posted by PopyCaste View Post
I want to customize this sample .bashrc file http://tldp.org/LDP/abs/html/sample-bashrc.html. But it doesn't work, because the two mentioned environment variables aren't set by default.
Right.

Quote:
Please have a look on the link above and search for "DISPLAY" in it, for example. The author uses if-clauses to determine, on which system we are, using the DISPLAY-variable, doesn't he?
But as you say, normally the variable is not set by default and as a result, i get one error message on every command i enter on the shell..
Well, the author might be one of those that never operate outside X, that's why s/he probably didn't notice this problem. However, it's a very obvious error.

Quote:
My question is, how can I change it?
You could check if $HOST is set, and if it's not set, set it to a default value. I don't know the purpose of that value, so I can't figure out what would be a good default value.

Note also that that script loads by default /etc/bashrc, while some distros often use /etc/bash/bashrc.

I don't have the time to review the whole rc file right now, and it just seems to me way too complicated, just to get fancy useless stuff in your prompt. It's about tastes, though.

Quote:
And why this could be a working sample .bashrc-file when obviously the environment variables - that are used - are not initialized by default.
I don't know. It seems that this rc file is not too well tested, and it's also old (though that shouldn't matter).

Quote:
When I export the two variables, they won't be there after rebooting, right?

Best regards!
Right. But you could export them at the very beginning of the script. Not that it would make much sense, though.
i92guboj is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 03:08 PM.

Powered by vBulletin 3.6.8 ©2000 - 2007, content relevant URLs by vBSEO, Property of Core Root.

Content Relevant URLs by vBSEO 3.0.0