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
UDHCPC(8)						 GNU/Linux Administrator's Manual						 UDHCPC(8)

NAME
udhcpc - very small DHCP client SYNOPSIS
udhcpc [OPTION]... DESCRIPTION
The udhcp client negotiates a lease with the DHCP server and executes a script when it is obtained or lost. OPTIONS
-c CLIENTID, --clientid=CLIENTID Send the client identifier CLIENTID. -f, --foreground Do not fork after obtaining a lease. -H HOSTNAME, --hostname=HOSTNAME Send the client hostname HOSTNAME. -h HOSTNAME Alias for -H HOSTNAME. -i INTERFACE, --interface=INTERFACE Configure INTERFACE. -n, --now Exit with failure if a lease cannot be obtained. -p FILE, --pidfile=FILE Write the process ID of the daemon to FILE. -q, --quit Exit after obtaining a lease. -r ADDRESS, --request=ADDRESS Request IP address ADDRESS. -s FILE, --script=FILE Use script FILE. -v, --version Display version. USAGE
When an event occurs, udhcpc executes a script. There are four possible arguments to this script: deconfig deconfig is used when udhcpc starts, and when a lease is lost. The script should put the interface in an up, but deconfigured, state. bound bound is used when udhcpc moves from an unbound to a bound state. The script should configure the interface and set any other rele- vant parameters (e.g., default gateway, dns server, etc.). renew renew is used when udhcpc when a lease is renewed. The interface is already configured, so the IP address will not change. Other parameters (e.g., default gateway, subnet mask, dns server) may. nak nak is used when udhcpc receieves a NAK packet from the server. The enviromental variable $message will contain the reason for the NAK message if the server included one. Processing this message is optional, as the script will also be called with deconfig if need be. Parameters are passed to the script via the following environment variables: HOME The inherited HOME, or "/" if it is unset. PATH The inherited PATH, or "/bin:/usr/bin:/sbin:/usr/sbin" if it is unset. interface The interface. ip The client IP address. siaddr The BOOTP next server option. sname The BOOTP server name option. boot_file The BOOTP boot file option. subnet The subnet mask. timezone The timezone offset from UTC in seconds. router The list of routers. timesvr The list of time servers. namesvr The list of IEN 116 name servers. dns The list of DNS servers. logsvr The list of MIT-LCS UDP log servers. cookiesvr The list of RFC 865 cookie servers. lprsvr The list of LPR servers. hostname The host name. bootsize The length in 512-octet blocks of the bootfile. domain The domain name of the network. swapsvr The client's swap server. rootpath The path of the client's root dist. ipttl The TTL. mtu The MTU. broadcast The broadcast address. ntpsrv The list of NTP servers. wins The list of WINS servers. lease The lease time in seconds. dhcptype The DHCP message type (safely ignored). serverid The server IP address. message Reason for a DHCPNAK. tftp The TFTP server name. bootfile The bootfile name. FILES
/usr/share/udhcpc/default.script Script run when leases are obtained or lost. NOTES
udhcpc responds to the following signals: SIGUSR1 This signal causes udhcpc to renew the current lease or, if it does not have one, obtain a new lease. SIGUSR2 This signal caused udhcpc to release the current lease. GNU
/Linux 2001-09-26 UDHCPC(8)
All times are GMT -4. The time now is 09:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy