Sponsored Content
Operating Systems AIX When/how is $HOSTNAME populated ? Post 302331643 by Browser_ice on Monday 6th of July 2009 08:22:15 PM
Old 07-06-2009
Question When/how is $HOSTNAME populated ?

When and how is the variable $HOSTNAME populated ?

I am asking because I had a weird situation that just happened.

I have created backup scripts that do backups on different servers. Each servers has different folders to be backed up. So I had included a check on $HOSTNAME to find out which folders to back up.

But tonight, when I started the backup on one server, the backup did not start because it said I was on the wrong server (my coding). I turned out aht the content of the $HOSTNAME was empty. All the other servers had no problems starting the same exact backup script as it $HOSTNAME was containing the right servename.

Here are the steps I did immediatlly after:
A) Checking the content of the $HOSTNAME variable:
- I logged with my own operator userid and did "echo $HOSTNAME". It had the servername in it
- I did a "sudo echo $HOSTNAME" and the content was empty
- I did a "sudo su -" then a "echo $HOSTNAME and the variable had the server name in it.
B) I opened up another window and did the same steps as in A) and all 3 steps showed that $HOSTNAME had a servername content.

I had to resort doing a "sudo su -" and start the backup. Otherwise, I would have had to change the script as a quick workaround.

Somehow, on that specific xterm window I had opened, the content of the $HOSTNAME variable was not populated in all cases. I want to know how this happened and why as it may happen again with another operator (they don't know how to script).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Hostname

Hello, I am installing redhat linux 6.2 on an intel based system. Whether i want to know any naming conventions should i follow. ie Any convention to follow to name a linux machine(To give hostname). Simillarly for domain name also. Please suggest in this regard (1 Reply)
Discussion started by: bache_gowda
1 Replies

2. IP Networking

looking up hostname

Using Solaris 8 (or WINXP). I am trying to look up a specific DNS hostname, but I don't know which DNS server houses that entry. How can I find the hostname? nslookup gives me the following: C:\>nslookup hostname Server: dnsserver Address: x.x.x.x *** dnsserver can't find hostname:... (2 Replies)
Discussion started by: dangral
2 Replies

3. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies

4. UNIX for Dummies Questions & Answers

Printing hostname

Hi, I am using hostname environment variable in my shell script to print the host name but it's printing nothing.Can you please help me on this. Please find the part of the code pasted here: llist= llist=$(ps -ef | grep -v grep | grep -c "$1") echo "Hostname is ${hostname}" (7 Replies)
Discussion started by: gbiswal
7 Replies

5. UNIX for Dummies Questions & Answers

Log file not getting populated when using BTEQ

Hi, I am trying to run some SQL scripts under the UNIX server using BTEQ. When I try to create a log file, the file gets populated only to the point where I log into BTEQ. The log file for the running of the actual script does not seem to be stored. Would any one know ehy this could be... (3 Replies)
Discussion started by: zsrinathz
3 Replies

6. SCO

Possible hostname issue?

from the hostname command I get this: scosysv.mycompany0 when I ping scosysv.mycompany0 i get 64.158.xx.xx which fails with 100% packet loss. /etc/hosts shows 199.199.199.1 scosysv scosysv.mycompany0 scosysv.mycompany0.com when I ping the hostname value isn't the local IP 199.199.199.1... (6 Replies)
Discussion started by: bbxguy
6 Replies

7. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

8. AIX

Hard Drive stuck in populated state?

Hi all, I ended up replacing a failed disk drive on my power 7. I had a few issues with unmirroring as it had a stale logical volume. I ended up finally getting it to unmirror the rootvg. I had an empty space in slot 3 so I ended up putting the new disk in slot 3. It configured to hdisk0 with no... (2 Replies)
Discussion started by: AlexanderIII
2 Replies

9. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

10. Web Development

How to get input text boxes populated / perl cgi?

Hi, I know how to populate a combo box or a drop down list box which I do as under : Query that gets the data for the drop down box : $qry = "select \"EmployeeID\" AS empid, \"FirstName\"::text || ' ' ||\"LastName\"::text as name from \"Employees\""; $qq =... (1 Reply)
Discussion started by: terrykhatri531
1 Replies
HOSTNAME(7)						     Linux Programmer's Manual						       HOSTNAME(7)

NAME
hostname - hostname resolution description DESCRIPTION
Hostnames are domains, where a domain is a hierarchical, dot-separated list of subdomains; for example, the machine monet, in the Berkeley subdomain of the EDU domain would be represented as "monet.Berkeley.EDU". Hostnames are often used with network client and server programs, which must generally translate the name to an address for use. (This task is generally performed by either getaddrinfo(3) or the obsolete gethostbyname(3).) Hostnames are resolved by the Internet name resolver in the following fashion. If the name consists of a single component, that is, contains no dot, and if the environment variable HOSTALIASES is set to the name of a file, that file is searched for any string matching the input hostname. The file should consist of lines made up of two white-space sepa- rated strings, the first of which is the hostname alias, and the second of which is the complete hostname to be substituted for that alias. If a case-insensitive match is found between the hostname to be resolved and the first field of a line in the file, the substituted name is looked up with no further processing. If the input name ends with a trailing dot, the trailing dot is removed, and the remaining name is looked up with no further processing. If the input name does not end with a trailing dot, it is looked up by searching through a list of domains until a match is found. The default search list includes first the local domain, then its parent domains with at least 2 name components (longest first). For example, in the domain CS.Berkeley.EDU, the name lithium.CChem will be checked first as lithium.CChem.CS.Berkeley.EDU and then as lithium.CChem.Berkeley.EDU. Lithium.CChem.EDU will not be tried, as there is only one component remaining from the local domain. The search path can be changed from the default by a system-wide configuration file (see resolver(5)). SEE ALSO
gethostbyname(3), resolver(5), mailaddr(7), named(8) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2010-11-07 HOSTNAME(7)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy