>> Read No. 10431 article  
[질문]hostid 바꾸는법

등록 2000-11-04 04:21:00     조회 2
이름 김영균    

		안녕하세요
저는 레드햇 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 at 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:
 */
이름
암호
Register [ localhost 목록보기 윗글 아랫글
글쓰기
답장쓰기 수정 삭제
정규표현식 [ 상세 검색 ]
페이지로딩: [ 1.91 초 ] 작업시간: [ 1.53 초 ]

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved
[TOP]

적수네 동네
+
| 적수네 동네
| 공부방
| 리눅스 잡지 서고
| LSN 소스
| 링크 모음
+---+
게시판
+
| 떠들어보세!
| 질문과 답변
| 새소식과 정보
| 1원짜리 팁?
| 대화방
+---+
칼럼?
+
| 세하 훔쳐보기
| Welcome2nite
| 혜진의 염장판
+---+
리눅스 상표권
+
| 반대 서명란
| 토론 게시판
+---+
GNU
+
| GNU 선언문
| GNU GPL
| GNU 미러 목록
+---+
프로젝트?
+
| 리눅스카운터
| RC5DES
| 실질헌법 제작
+---+
커널 소식
+
| 안정 버젼: 2.4.14
+---+
테마 선택
+
LSN 방송국?
+
| OFF AIR
+---+
회원
+
| 로그인
+---+
[ 적수네 동네 ] [ 리눅스 상표권 독점 반대 ] [ 한글 리눅스 문서 프로젝트 ] [ KrLine ] [ 사랑넷 ] [ Valid HTML 4.0! ] [ SlashDot ] [ Freshmeat ]
Copyleft (C) 1998-2001 Byeong-Chan Kim . License
TIME: 1789739141
System by WYZsoft, HDD by I.O.Linux, Mizi Research, Embryo, WOWLINUX, Domain by SarangNet, Network by KrLine.