- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to get the hostname when in single user mo...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:29 AM
03-05-2004 07:29 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:38 AM
03-05-2004 07:38 AM
Re: how to get the hostname when in single user mode
And if you mount /usr, you could run the hostname commnad.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:45 AM
03-05-2004 07:45 AM
Re: how to get the hostname when in single user mode
echo "hostname/S" | adb /stand/vmunix /dev/kmem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:47 AM
03-05-2004 07:47 AM
Re: how to get the hostname when in single user mode
And, Mr. Wallek has what I'm looking for a file where the there is only one entry and should be authoriative. althought grep is in /usr and unavailable, /sbin/awk should work just as well.
otherways, were writing a C program not using shared libraries. and the output from /sbin/uname -n, which is unknown in single user mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:47 AM
03-05-2004 07:47 AM
Re: how to get the hostname when in single user mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 08:00 AM
03-05-2004 08:00 AM
Re: how to get the hostname when in single user mode
Patrick had the answer. That's the most possible hostname that would get assigned to the system later.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 08:17 AM
03-05-2004 08:17 AM
Re: how to get the hostname when in single user mode
-----------------------------------------
#include
#include
extern int errno;
int main()
{
int cc = 0;
char s[80];
cc = gethostname(s,(size_t) (sizeof(s) - 1));
if (cc == 0)
{
(void) printf("%s\n",s);
}
else
{
cc = (errno != 0) ? errno : -1;
(void) fprintf(stderr,"Gethostname failed. (%d)\n",cc);
}
return(cc);
}
--------------------------------------------
Compile gethostname.c like this (It will even compile with the Bundled compiler):
cc +DAportable -Wl,-a,archive -o gethostname gethostname.c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 08:50 AM
03-05-2004 08:50 AM
Re: how to get the hostname when in single user mode
else mount /usr (vgchange -a y /dev/vg00 ;mount /dev/vg00/lvol7 /usr)
then
#grep "HOSTNAME=" /etc/rc.config.d/netconf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 12:39 PM
03-05-2004 12:39 PM
Re: how to get the hostname when in single user mode
/sbin/awk '/HOSTNAME=/ {print;}' /etc/rc.config.d/netconf
but it returns lines and not really the value. And, with the possibilities of multiple lines, comments, and quoting, I think this works best for getting the value from netconf:
/sbin/sh -c ". /etc/rc.config.d/netconf;print $HOSTNAME"
Mr. Stephenson's program works. but it returns the same value as /sbin/uname -n would, i.e. it will report the hostname as "unknown" when in single user mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2004 03:01 PM
03-06-2004 03:01 PM
Re: how to get the hostname when in single user mode
Bill Hassell, sysadmin