linuxÁ½¸ö³ÌÐòͨ¹ý¹²ÏíÄÚ´æͨÐŵÄÒ»¸ö¼òµ¥Àý×Ó
д¹²ÏíÄÚ´æ³ÌÐò£º
/*
* File: server.cpp
* Author: centos
*˵Ã÷£º´Ó¼üÅ̶ÁÈëÊý¾Ý£¬´æ·ÅÔÚ¹²ÏíÄÚ´æÖС£
* Created on 2010Äê3ÔÂ1ÈÕ, ÏÂÎç3:44
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define BUF_SIZE 1024
#define MYKEY 114
int main(int argc, char** argv)
{
int shmid;
char *shmptr;
struct shmid_ds shmbuf;
system("ipcrm -M114"); //µ÷ÊÔ³ÌÐòʱÓÃ
shmid = shmget(MYKEY, BUF_SIZE, (IPC_CREAT |0777) );
if ( -1 == shmid )
{
printf("server shmget error!\n");
fprintf(stderr, "Error: %d - %s\n", errno, strerror(errno));
exit(1);
}
shmptr = (char *) (shmat(shmid, 0, 0)) ;
if ( -1 == (int) shmptr )
{
printf("server shmat error!\n");
fprintf(stderr, "Error: %d - %s\n", errno, strerror(errno));
if(shmctl(shmid,IPC_RMID,&shmbuf) < 0)
{
perror("shmctl error");
fprintf(stderr, "Error: %d - %s\n", errno, strerror(errno));
}
exit(1);
}
strcpy(shmptr,"this is a test. \n");
while(1)
{
printf("Please input:");
scanf("%s",shmptr) ;
while ('\n' != getchar() );
// fflush(stdin);
// printf("your input: %s\n", shmptr);
if (! strcmp(shmptr,"quit")) break;
}
shmdt(shmptr);
if(shmctl(shmid,IPC_RMID,&shmbuf) < 0) perror("shmctl error");
return (EXIT_SUCCESS);
}
¶Á¹²ÏíÄÚ´æµÄ³ÌÐò£º
/*
* File: main.cpp
* Author: centos
*
˵Ã÷£º´Ó¹²ÏíÄÚ´æÖжÁÈ¡Êý¾Ý£¬ÏÔʾµ½ÆÁÄ»ÉÏ¡£
* Created on 2010Äê3ÔÂ2ÈÕ, ÉÏÎç10:47
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define BUF_SIZE 1024
#define M
Ïà¹ØÎĵµ£º
Ò»¡¢Ê²Ã´ÊÇinit
¡¡¡¡initÊÇLinuxϵͳ²Ù×÷Öв»¿ÉȱÉٵijÌÐòÖ®Ò»¡£ ÊÇÒ»¸öÓÉÄÚºËÆô¶¯µÄÓû§¼¶½ø³Ì¡£
¡¡¡¡ÄÚºËÆô¶¯£¨ÒѾ±»ÔØÈëÄڴ棬¿ªÊ¼ÔËÐУ¬²¢Òѳõʼ»¯ËùÓеÄÉ豸Çý¶¯³ÌÐòºÍÊý¾Ý½á¹¹µÈ£©Ö®ºó£¬¾Íͨ¹ýÆô¶¯Ò»¸öÓû§¼¶³ÌÐòinitµÄ·½Ê½À´Æô¶¯ÆäËûÓû§¼¶µÄ½ø³Ì»ò·þÎñ¡£ËùÒÔ£¬initʼÖÕÊǵÚÒ»¸ö½ø³Ì£¨ÆäPIDʼÖÕΪ1£©¡£
¡¡¡¡ÄÚºË ......
½ñÌì×°ÁËÒ»ÌìµÄLinuxϵͳ£¬ÓëÆä˵°²×°»¹²»Èç˵ÊÇÏÂÔØÁËÒ»Ì죬ÏȺó×°ÁËfedora core 4£¬fedora core 6£¬×îºó×°fedora core 8ÖÕÓÚ¿ÉÒÔÓÃÁË£¬Ã¿¸ö¶¼ÊÇ3G¶à£¬ÒòΪÔÚѧУµÄ¹¤×÷ÊÒ£¬ËùÒÔÏÂÔØËÙ¶Èƽ¾ù¿ÉÒÔ´ïµ½1.9M²»µ½£¬Õâ¿ÉÊÇÏÞËٵģ¬¾ÍËãÕâÑùÎҵĵçÄÔÒ²ÒòΪÏÂÔØËÙ¶ÈÌ«¿ìËÀÁËN»ØÁË£¬¶¼ÊÇÇ¿ÖÆPowerµÄ£¬ÕæµÃ×°µÃÓеãÓôÃÆ°¡£¬×°FC4ÊÇÒ ......
linuxϼ¸ÖÖ·þÎñÆ÷µÄÅäÖÃʹÓÃÖ®Ò»£ºnfs tftp
°²×°nfsÐèÒªÔÚ·þÎñÆ÷¶Ë¹Ø±Õiptables·À»ðǽ£¬¹Ø±Õ·½·¨ÈçÏÂ
²é¿´·À»ðǽ״̬£º
/etc/init.d/iptables status
ÔÝʱ¹Ø±Õ·À»ðǽ£º
/etc/init.d/iptables stop
½ûÖ¹·À»ðǽÔÚϵͳÆô¶¯Ê±Æô¶¯
/sbin/chkconfig --level 2345 iptables off
ÖØÆôiptables:
/etc/init.d/iptabl ......
st='abcd'
1.×Ö·û´®³¤¶È
expr length $st »òÕß ${#st}
2.È¡×Ö·û´®µÄsubstring
expr substr "$var" startpos length »òÕß ${var:m} ${var:m:len}
${var:m}ÖеÄmµÄÈ¡Öµ´Ó0µ½${#var}-1£¬Æä·µ»ØµÄÊÇ´ÓµÚm¸ö×Ö·ûµ½×îºóµÄ²¿·Ö£»ÀýÈçecho ${st:1}µÄ½á¹ûÊÇ'bcd'
expr substr "$var" startpos length ÖеÄstartposÈ¡Öµ·¶Î§ÊÇ ......