1 /* hostname.c - Get/Set the hostname
3 * Copyright 2012 Andre Renaud <andre@bluewatersys.com>
5 * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/hostname.html
7 USE_HOSTNAME(NEWTOY(hostname, NULL, TOYFLAG_BIN))
13 usage: hostname [newname]
15 Get/Set the current hostname
21 void hostname_main(void)
23 const char *hostname = toys.optargs[0];
25 if (sethostname(hostname, strlen(hostname)))
26 perror_exit("set failed '%s'", hostname);
28 if (gethostname(toybuf, sizeof(toybuf))) perror_exit("get failed");