>> Edit article
이름
제목
패스워드
안녕하세요 저는 레드햇 6.x 버전을 쓰고 있는데 hostid 를 바꾸려고 합니다. 어떻게 해야 하는지... 쩝... 누가 sethostid를 이용해서 프로그램을 만들었는데 실행시키면 redhat6.0에서는 sethostid: No such file or directory라고 하구 redhat6.2에서도 마찬 가지죠..흑흑... 이찌하면 좋을런지.... 현재 hostid = 7f0100 바꿀ID 7f8beeae /* hostid.c New hostid for Linux. Date: 1997-03-23 18:30:00 Last Change: 1997-03-23 20:36:48 Copyright (C) 1997 Sander van Malssen <svm@kozmix.ow.nl> This software is released under the GNU Public Licence. See the file `COPYING' for details. */ static char *rcsid = "$Id: hostid.c,v 1.1 1997/03/23 19:43:14 svm Exp svm $"; #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> char *progname; void usage (int exitval) { fprintf (exitval ? stderr : stdout, "usage:" " printing the hostid:" " %s" " setting the hostid:" " %s [id] set hostid to [id]" " %s -e set hostid to first ethernet address" " general options:" " -v verbose" " -x use hexadecimal", progname, progname, progname); exit (exitval); } int main (int ac, char **av) { int ret, verbose = 0, hex = 0, ether = 0; unsigned long id; progname = av[0]; while ((ret = getopt (ac, av, "vxeh")) != EOF) { switch (ret) { case 'x': hex = 1; break; case 'v': verbose = 1; break; case 'e': ether = 1; break; case 'h': usage (0); break; default: usage (1); break; } } if (ac == optind && !ether) { /* GET */ id = gethostid (); if (id == 0 && verbose) { printf ("Hostid not set"); exit (0); } if (verbose) printf ("hostid is %lu (0x%08lx)", id, id); else if (hex) printf ("0x%08lx", id); else printf ("%lu", id); exit (0); } else { /* SET */ if (ether && ac > optind) { fprintf (stderr, "%s: can't both use -e and specify [id]", progname); usage(2); } if (ether) { FILE *fp; char line[1024], addrstring[32], *p = NULL, *q; if ((fp = popen ("/sbin/ifconfig eth0", "r")) == NULL) { fprintf (stderr, "%s: can't run ifconfig: %s", progname, strerror (errno)); exit (1); } while (fgets (line, 1024, fp)) { if ((p = strstr (line, "HWaddr"))) { p += 7; break; } } pclose (fp); if (p == NULL) { fprintf (stderr, "%s: no hardware address found", progname); exit (1); } q = addrstring; while (*p && *p != '') { if (*p != ':') *q++ = *p++; else p++; } id = strtoul (addrstring, NULL, 16); } else id = strtoul (av[ac - 1], NULL, hex ? 16 : 10); ret = sethostid (id); if (ret) { fprintf (stderr, "%s: sethostid: %s", progname, strerror (errno)); exit (1); } if (verbose) printf ("hostid set to %lu (0x%08lx)", id, id); exit (0); } } /* Local variables: rm-trailing-spaces: t End: */
Copyleft
1999-2026 by
JSBoard Open Project
Theme Designed by
IDOO
All right reserved