Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÖÐerrnoʹÓÃ

µ±linuxÖеÄC apiº¯Êý·¢ÉúÒ쳣ʱ,Ò»°ã»á½«errno±äÁ¿(Ðèinclude
errno.h)¸³Ò»¸öÕûÊýÖµ,²»Í¬µÄÖµ±íʾ²»Í¬µÄº¬Òå,¿ÉÒÔͨ¹ý²é¿´¸ÃÖµÍÆ²â³ö´íµÄÔ­Òò£¬ÔÚʵ¼Ê±à³ÌÖÐÓÃÕâÒ»Õнâ¾öÁ˲»ÉÙÔ­±¾¿´À´ÄªÃûÆäÃîµÄÎÊÌâ¡£µ«ÊÇ
errnoÊÇÒ»¸öÊý×Ö£¬´ú±íµÄ¾ßÌ庬Ò廹Ҫµ½errno.hÖÐÈ¥ÔĶÁºê¶¨Ò壬¶øÃ¿´Î²éÔÄÊÇÒ»¼þºÜ·±ËöµÄÊÂÇé¡£ÓÐÏÂÃæ¼¸ÖÖ·½·¨¿ÉÒÔ·½±ãµÄµÃµ½´íÎóÐÅÏ¢
(1)void perror(const char *s)
º¯Êý˵Ã÷
perror ( )ÓÃÀ´½«ÉÏÒ»¸öº¯Êý·¢Éú´íÎóµÄÔ­ÒòÊä³öµ½±ê×¼´íÎó(stderr),²ÎÊýs ËùÖ¸µÄ×Ö·û´®»áÏÈ´òÓ¡³ö,ºóÃæÔÙ¼ÓÉÏ´íÎóÔ­Òò ×Ö·û´®¡£´Ë´íÎóÔ­ÒòÒÀÕÕÈ«¾Ö±äÁ¿ errno µÄÖµÀ´¾ö¶¨ÒªÊä³öµÄ×Ö·û´®¡£
(2) char *strerror(int errno)
½«´íÎó´úÂëת»»Îª×Ö·û´®´íÎóÐÅÏ¢,¿ÉÒÔ½«¸Ã×Ö·û´®ºÍÆäËüµÄÐÅÏ¢×éºÏÊä³öµ½Óû§½çÃæÀýÈç
fprintf(stderr,"error in CreateProcess %s, Process ID %d ",strerror(errno),processID)
×¢£º¼ÙÉèprocessIDÊÇÒ»¸öÒѾ­»ñÈ¡Á˵ÄÕûÐÎID
(3)printf("%m", errno);
ÁíÍâ²»ÊÇËùÓеĵط½·¢Éú´íÎóµÄʱºò¶¼¿ÉÒÔͨ¹ýerror»ñÈ¡´íÎó´úÂ룬ÀýÈçÏÂÃæµÄ´úÂë¶Î
/*×¢£ºÏÂÃæµÄÍ·ÎļþʹÓÃ""¶øÃ»ÓÐÖ±½ÓʹÓüâÀ¨ºÅÊÇÒòΪ²©¿Í´ó°ÍÖмâÀ¨ºÅµ±×÷html·ûºÅ£¬ËùÒÔÆäÄÚ²¿µÄÍ·ÎļþÃû×ֻᱻֱ½ÓºöÂÔ*/
#include"stdio.h"
#include "stdlib.h"
#include "errno.h"
#include "netdb.h"
#include "sys/types.h"
#include "netinet/in.h"
int main (int argc, char *argv[])
{
struct hostent *h;
if (argc != 2)
{
fprintf (stderr ,"usage: getip address\n");
exit(1);
}
/* È¡µÃÖ÷»úÐÅÏ¢ */
if((h=gethostbyname(argv[1])) == NULL)
{
/* Èç¹ûgethostbyname ʧ°Ü£¬Ôò¸ø³ö´íÎóÐÅÏ¢ */
herror(“gethostbyname”);
exit(1);
}
/* ÁÐÓ¡³ÌÐòÈ¡µÃµÄÐÅÏ¢ */
printf(“Host name : %s\n”, h->h_name);
printf(“IP Address : %s\n”, inet_ntoa (*((struct in_addr *)h->h_addr))£©;
return 0;
}
/*************************************/
ͨ¹ýÉÏÃæµÄ´úÂë¿ÉÒÔ¿´µ½£ºÊ¹ÓÃgethostbyname()º¯Êý£¬Äã²»ÄÜʹÓÃperror()À´Êä³ö´íÎóÐÅÏ¢£¨ÒòΪ´íÎó´úÂë´æ´¢ÔÚ h_errno Öжø²»ÊÇerrno ÖС£ËùÒÔ£¬ÄãÐèÒªµ÷ÓÃherror()º¯Êý¡£
Äã
¼òµ¥µÄ´«¸øgethostbyname() Ò»¸ö»úÆ÷Ãû£¨&ldq


Ïà¹ØÎĵµ£º

Èý¿î Linux ϵÄÃâ·Ñ×ÀÃæ¼¶É±¶¾Èí¼þ(ͼ)


ÓÉÓÚ Linux Á¼ºÃµÄÓû§È¨ÏÞ¹ÜÀíÌåϵ£¬²¡¶¾ÍùÍùÊÇ Linux ϵͳ¹ÜÀíÔ±×îºó²ÅÐèÒª¿¼ÂǵÄÎÊÌâ¡£ÒÔÍù£¬Linux ÉϵÄɱ¶¾Èí¼þÖ÷ÒªÊÇΪÆóÒµµÄÓʼþºÍÎļþ·þÎñÆ÷ËùÉè¼ÆµÄ¡£Èç½ñ£¬Ëæ×Å Linux ×ÀÃæÓû§ÊýÁ¿µÄÔö³¤£¬×ÀÃæÓû§ÔÚÊÜÒæÓÚ Linux ϵͳ¶Ô²¡¶¾½ÏÇ¿µÄÌìÈ»ÃâÒßÁ¦µÄͬʱ£¬Ò²ÐèҪɱ¶¾Èí¼þÇåÀí´ÓÍøÂç»òUÅÌ´øÀ´µÄWIndows²¡¶¾¡£¾¡¹ÜÄÇЩ ......

linux½âѹtarÃüÁî


linux½âѹ tarÃüÁî
tarÃüÁî
tar [-cxtzjvfpPN] ÎļþÓëĿ¼ ....

²ÎÊý£º
-c £º½¨Á¢Ò»¸öѹËõÎļþµÄ²ÎÊýÖ¸Áî(create µÄÒâ˼)£»
-x
£º½â¿ªÒ»¸öѹËõÎļþµÄ²ÎÊýÖ¸Á
-t £º²é¿´ tarfile ÀïÃæµÄÎļþ£¡
ÌØ±ð×¢Ò⣬ÔÚ²ÎÊýµÄÏ´ïÖУ¬ c/x/t ½öÄÜ´æÔÚÒ»¸ö£¡²»¿Éͬʱ´æÔÚ£¡
ÒòΪ²»¿ÉÄÜͬʱѹËõÓë½âѹËõ¡£
-z £ºÊ ......

LinuxϵͳSudoÃüÁîµÄʹÓÃ˵Ã÷

“Sudo” ÊÇUnix/Linuxƽ̨ÉϵÄÒ»¸ö·Ç³£ÓÐÓõŤ¾ß£¬ËüÔÊÐíϵͳ¹ÜÀíÔ±·ÖÅ䏸ÆÕͨÓû§Ò»Ð©ºÏÀíµÄ“ȨÀû”£¬ÈÃËûÃÇÖ´ÐÐһЩֻÓг¬¼¶Óû§»òÆäËûÌØÐíÓû§²ÅÄÜÍê³ÉµÄÈÎÎñ£¬±ÈÈ磺ÔËÐÐһЩÏñmount£¬halt£¬suÖ®ÀàµÄÃüÁ»òÕ߱༭һЩϵͳÅäÖÃÎļþ£¬Ïñ/etc/mtab£¬ /etc/samba/smb.confµÈ¡£ÕâÑùÒÔÀ´£ ......

LinuxÖ÷»ú¼à¿Ø¹¤¾ßmunin monit ntop

À´Ô´£ºhttp://linux.chinaunix.net/ebook/doc/2009/09/17/1135830.shtml
±¾ÎĽéÉÜÔÚcentos 5.x»·¾³ÏÂͨ¹ýyumÔ´µÄÀ©Õ¹Ê¹ÓÃmunin¡¢ monit¡¢ntop¹¤¾ßÀ´¼à¹ÜÄãµÄÓ¦ÓóÌÐòºÍ·þÎñÆ÷¡£ÌâΪÀÁÈË˵˵µÄÊǼò±ãµÄ°²×°·½Ê½¶øÒÑ£¬½«Ç¿´óµÄ¹¦ÄÜÅäÖüòµ¥µÄÓ¦ÓÃÆðÀ´ÊǺÜÖØÒªµÄ£¬¿ÉÒÔ½Úʡʱ¼ä²¢Ìá¸ßЧÂÊ¡£
Monit£ºhttp:#www.tildeslas ......

LinuxϵͳÉϼÜÉèVSFTP·þÎñÆ÷ʵÀý½âÎö

     
ʵÑé»·¾³£ºAS4×îС»¯°²×°
ʵÑéÄ¿±ê£º¼ÜÉèVSFTP·þÎñÆ÷
Õâ´ÎÎÒÃÇÀ´Ñ§Ï°LinuxϵͳÖÐµÄ vsftp·þÎñÆ÷µÄÅäÖá£
ÏÂÃæÎÒÃÇ¿ªÊ¼ÁË£¡Ê×ÏÈÎÒÃǰ²×°vsftp·þÎñÆ÷¶ËµÄÈí¼þ¡£
vsftpd·þÎñÆ÷µÄ°²×°ÎļþλÓÚµÚ1ÕŰ²×°¹âÅÌÖС£
ʹÓÃrpmÃüÃû¿É˳Àû°²×°¸ÃÈí¼þ°ü¡£
# rpm -ivh vsftpd-2.0.1-5.i386.r ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ