- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- HP UX 11.23 uname issue with c programm
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
01-24-2011 06:44 AM
01-24-2011 06:44 AM
HP UX 11.23 uname issue with c programm
#include
void main()
{
struct utsname uts;
uname(&uts);
printf("name =%s",uts.sysname);
printf("\n name =%s",uts.nodename);
}
hi my node name is more than 8 characters
pumass00001 130: uname -a
HP-UX pumass0001 B.11.31 U ia64 1883224899 unlimited-user license
so i executed this programm i am getting
pumass00001 128: ./a.out
sys name =HP-UX
nodename =pumass00pumass00001
why this type of output comming?
- Tags:
- long hostname
- uname
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 09:09 AM
01-24-2011 09:09 AM
Re: HP UX 11.23 uname issue with c programm
In HP-UX, the hostname and nodename are the same by default. But the nodename cannot be longer than 8 characters unless the "Node and Host Name Expansion" optional package is installed:
https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=NodeHostNameXpnd
Apparently you just discovered what happens if your nodename is longer than 8 characters and the NodeHostNameXpnd package is not installed.
If you want your hostname to be longer than 8 but less than 64 characters, that can be done without the expansion package; but then you must configure an extra variable NODENAME in your /etc/rc.config.d/netconf file, to explicitly set a nodename that is 8 characters or less.
The nodename is historically used by the UUCP utilities; the hostname is what is used in the context of Internet Domain Name Service (DNS).
Unless you're doing something related to UUCP, you should probably use the gethostname(2) function instead, and leave the legacy uts.nodename alone.
#include
#include
int main() {
char *hostname_buf = NULL;
size_t hostname_size;
/* get the max size of hostname: */
/* it's typically 64 or 256, but may be */
/* longer in future HP-UX versions */
hostname_size = sysconf(_SC_HOST_NAME_MAX);
/* create a buffer of required size*/
hostname_buf = malloc(hostname_size);
if (hostname_buf == NULL) {
/* critically out of memory */
exit(1);
}
gethostname(hostname_buf, hostname_size);
printf("name = %s\n", hostname_buf);
return 0;
}
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 12:42 PM
01-24-2011 12:42 PM
Re: HP UX 11.23 uname issue with c programm
>my node name is more than 8 characters
HP-UX pumass0001 B.11.31 U ia64
You do realize you are in for a heap of trouble.
>I am getting: nodename =pumass00pumass00001
>why this type of output coming?
How are you compiling this program? Are you checking the return value? What is errno?
Have you looked at the documentation for Node and Host Name Sizes on HP-UX: Using the Expanded Capabilities
>MK: But the nodename cannot be longer than 8 characters unless the "Node and Host Name Expansion" optional package is installed:
For 11.31, it's just a kernel parm, expanded_node_host_names(5).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 12:51 PM
01-24-2011 12:51 PM
Re: HP UX 11.23 uname issue with c programm
Using the Expanded Capabilities of HP-UX
http://bizsupport2.austin.hp.com/bc/docs/support/SupportManual/c01925495/c01925495.pdf
>void main()
This is required to be "int main".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 08:41 PM
01-24-2011 08:41 PM
Re: HP UX 11.23 uname issue with c programm
and uname_eoverflow=0 ,
then only we can set the node name more than 8 characters.
i am compiling this programm with aCC compiler.
so is uname function dose not obeying the kernel parameters.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2011 01:42 AM
01-25-2011 01:42 AM
Re: HP UX 11.23 uname issue with c programm
the uname(2) system call DOES respect the mentioned kernel parameters. By the way, you should also set the uname_eoverflow parameter because this will help older applications to detect the overflow error.
Please note that the default utsname structure used by your program does only use a character array of 9 bytes for the 'nodename' value. Please read the whitepaper referenced by Dennis, it would have told you to use the extra define -D_HPUX_API_LEVEL=20040821 to enlarge the utsname structure. Though, it is worth reading ;-)
Andi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2011 02:32 AM
01-25-2011 02:32 AM
Re: HP UX 11.23 uname issue with c programm
>so is uname function does not obeying the kernel parameters.
You basically told the kernel you don't care if the name is too long and worse, you didn't care to detect an error.