ÔÚC³ÌÐòÀïºÍshellͨÐÅ
Ò»°ãÎÒÃǵ÷ÓÃshell½Å±¾¶¼ÓÃsystem()À´ÊµÏÖ£¬È»ºó·¢ÏÖsytem·µ»ØÖµ²»ºÃ¿ØÖƶøÇÒת»»Âé·³(»¹ÒªÓÒÒÆ4λ¼´/256)£¬ÓÚÊÇÎÒÓÃpopenÀ´»ñÈ¡shellµÄ·µ»ØÖµ¡£¹ûÈ»ÔÚUnixÊÀ½çÀïÃæ£¬Í¨µÀ¾ÍÊÇÁ¬½á¸÷¸ö·½ÃæµÄÇÅÁº°¡£¡
´úÂëÀý×ÓÈçÏ£º
#include<stdio.h>
#include<stdlib.h>
#include<sys/wait.h>
int main (int argc, char *argv[])
{
char szline[256];
FILE *fp;
if (argc != 2)
{
printf ("usage: %s command\n", argv[0]);
return 0;
}
if ((fp = popen (argv[1], "r")) == NULL)
{
printf ("the command %s not exist\n", argv[1]);
return 0;
}
while (fgets (szline, sizeof (szline) - 1, fp) != NULL)
{
printf ("frome command:%s", szline);
}
pclose (fp);
return 0;
}
PS£ºÆæ¹ÖµÄÊÇÎÒÓÃÈçϺ¯Êý£º
char* get_cmd_result(char* cmd)
{
FILE *fp;
char result[256];
memset (result, 0,sizeof(result));
if((fp=popen(cmd,"r"))==NULL)
{
printf("the command %s not exist\n",cmd);
pclose(fp);
return 0;
}
while(fgets(result,sizeof(result)-1,fp)!=NULL)
{
#ifdef __DEBUG__
g_print("get result is %s\n", result);
#endif
}
pclose(fp);
return result;
}
ÔÚdebian sidϾÍûÎÊÌ⣬ÔÚUbuntu10.04Éϵ÷Óøú¯Êý¾Íû·¨·µ»ØµÄÕýÈ·Öµ£¬µ«ÔÚg¸Ãº¯ÊýÀïresultÊÇÕýÈ·µÄ£¬Õâ¸ö¾Í²»ÊǸÃÎÄÌÖÂÛµÄÎÊÌâÁË¡£
Ïà¹ØÎĵµ£º
1.ÇóÏÂÃæº¯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
int func(x)
{
int countx = 0;
while(x)
{
countx ++;
x = x&(x-1);
......
ÏÈÊÇÄÚºËÇý¶¯³ÌÐò£º
#include <linux/module.h>//¾ßÌåµÄÍ·ÎļþλÖÃΪ/opt/FriendlyARM/mini2440/linux-2.6.29/include/linux/*.h
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <l ......
ʲôÊÇmvcģʽ £¿
MVC ʽµÄ³öÏÖ²»½öʵÏÖÁ˹¦ÄÜÄ£¿éºÍÏÔʾģ¿éµÄ·ÖÀ룬ͬʱËü»¹Ìá¸ßÁËÓ¦ÓÃϵͳµÄ¿Éά»¤ÐÔ¡¢¿ÉÀ©Õ¹ÐÔ¡¢¿ÉÒÆÖ²ÐÔºÍ×é¼þµÄ¿É¸´ÓÃÐÔ
B/S ģʽºÍC/SģʽÓÐÊ²Ã´Çø±ð£¿
C/S½á¹¹£¬¼´Client/Server(¿Í»§»ú/·þÎñÆ÷)½á¹¹£¬ÊÇ´ó¼ÒÊìÖªµÄÈí¼þϵͳÌåϵ½á¹¹£¬Í¨¹ý½«ÈÎÎñºÏÀí·ÖÅäµ½Client¶ËºÍServer¶Ë£ ......
<select class="wellId" id="gasOriginWellId" name="gasOriginWellId" value="${mechWellForm.gasOriginWellId}" index="true">
< ......
µ¥Ïß³Ì
Single-Threaded(static) libc.lib
Debug Single-Threaded(static) & ......