grnmarker笔记

来源:互联网 发布:js获取点击事件 编辑:程序博客网 时间:2024/04/30 21:29

/usr/sbin/dadriveinfo 1 2>/dev/null| /bin/grep -F "Serial Number" | awk '{print $3}'


Drive:                                   Drive1 (/dev/xdb)
Type:                                    SATA
Model:                                   Hitachi HDS5C3020ALA632                 
Serial Number:                           ML0220F31ABGJN
Firmware Revision:                       ML6OA580
Size [KB] (1 KB = 1024 Bytes):           1953514584 KB
Size [GB] (1 GB = 1024^3 Bytes):         1863 GB
Size [GB] (1 GB = 10^9 Bytes):           2000 GB
Read Total  [MB] (1 MB = 1024^2 Bytes):  3496 MB
Write Total [MB] (1 MB = 1024^2 Bytes):  1392 MB
Read block requests:                     26079
Write block requests:                    18727
Last access:                             0 s ago
Failure reason:                          Not_Available
Disk cache:                              disabled


int main(void){    char cmd[64] = {0};    FILE *fp = NULL;    char file[64] = {0};    char string[512] = {0};    int result = 0;    int i = 0;    char *p = NULL;    sprintf(file, "mytmp");    //sprintf(cmd, "cat /proc/cpuinfo > mytmp");    //result = system(cmd);    //printf("%s", cmd);    fp = fopen(file, "r");    if(fp == NULL){        printf("%s is not exist", file);         return 0;    }       while(fgets(cmd, sizeof(cmd), fp) != NULL)    {           for(i = 0; i < GRN_KEYS_CNT; i++)        {               if(strncmp(cmd, grn_keys[i], strlen(grn_keys[i]))){             continue;            }               printf("%d\t**i=%d\tcmd=%s\t**grn_keys[%d] = %s\t\n", __LINE__, i, cmd, i, grn_keys[i]);                if((p = strchr(cmd, '\n')))                *p = 0;            printf("%d\tp = %s\tcmd=%s\n", __LINE__, p, cmd);            p = cmd + strlen(grn_keys[i]);            while(*p == ' ' || *p == '\t'){                p++;              printf("%d\tp = %s\tcmd=%s\n", __LINE__, p, cmd);            }               printf("%d\tp = %s\n", __LINE__, p);         }           //printf("%d\tp = %s\tq=%s\n", __LINE__, p, q);        }           return 0;  }



int static do_system_ret_buf(char *command, char *ret_buf, int buf_size){    char    *tmps;    int     pipefd[2];    pid_t   pid, childpid;    int     status, orig_stdin, rc;    if ((ret_buf == NULL) || (buf_size == 0))   /* caller should call system directly */        return system(command);    orig_stdin = dup(0);    if (orig_stdin < 0) {        return 1;    }    /* Flush all open output streams (stdout, in particular).  Without the flush,     * garbage can end up in ret_buf.     */    if (fflush(NULL) != 0) {        close(orig_stdin);        return 1;    }    if(pipe(pipefd)) {        close(orig_stdin);        return 1;    }    switch(pid=fork()){    case -1:        close(orig_stdin);        return 1;    case 0 : /* child's path */        /* pipefd[1] is for writing to the pipe. We want the output         * that used to go to the standard output (file descriptor 1)         * to be written to the pipe. The following command does this,         * creating a new file descripter 1 (the lowest available)         * that writes where pipefd[1] goes.         */        if (dup2(pipefd[1], 1) < 0)    /* points pipefd[1] at stdout */            exit(1);        close (pipefd[0]);          /* child isn't going to read from the pipe */        rc = system(command);        if (rc == 0)            exit(0);  // system call success        exit(1);    default: /* parent's path */        if (dup2(pipefd[0], 0) < 0) {  /* Set fd 0 (stdin) to read from the pipe */            dup2(orig_stdin, 0);            close(orig_stdin);            return 1;        }        close (pipefd[1]);          /* no need to write to the pipe */        close(pipefd[0]);           /* close the read pipe also */        tmps = ret_buf;        do {            *tmps = fgetc(stdin);        } while ((*tmps++ != EOF) && (--buf_size > 0));        tmps--;        *tmps = 0;        dup2(orig_stdin, 0);            /* restore original stdin */        close(orig_stdin);              /* close backup stdin */        childpid = waitpid(0, &status, 0);        if (WEXITSTATUS(status))        ;        else            return 0;  /* child exited normally and system call ok */        return 1;    }}


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 5岁宝宝乘飞机没带证件怎么办 网上订飞机票忘记订儿童票了怎么办 两岁宝宝对牛奶鸡蛋过敏了怎么办 两岁宝宝坐不住好跑怎么办 宝宝两岁多了不愿意坐小马桶怎么办 坐火车小孩拉屎在被子上怎么办 川航飞机票名字错了一个字怎么办 胜战本领怎么看走向战场怎么办 数数字油画你的颜料干了怎么办? 数字油画涂颜料涂错了怎么办 绝地求生模拟器注册已达上限怎么办 孕妇把番茄和虾一起吃了怎么办 4岁宝贝吃了玩具小电池怎么办 微信使用零钱需完善实名信息怎么办 两岁宝宝刷牙不会吐水怎么办 孩子牙龈上长了小牙怎么办 供暖公司未供暖却收取供暖费怎么办 两岁宝宝认知和语言能力低怎么办 蜡笔同步被对方发现删掉的怎么办 微信时间和手机时间不同步怎么办 孩子们家乡爱画美丽的也自己怎么办 娃把豆豆弄进鼻孔了怎么办 20岁了不知道自己该干什么怎么办 遇到一个新手买家恶意拍下怎么办 淘宝卖螃蟹有什么要求美工怎么办 淘宝衣服吊牌剪了想退货怎么办修 用图片在淘宝搜衣服搜不到怎么办 汽车黑塑料水砂纸磨的不平怎么办 sat报名要你填10位电话怎么办 手绘板连接电脑绘画有点迟钝怎么办 走路不小心滑了一下特尴尬怎么办 小孩子头撞了头发长不出来怎么办 小孩子头磕破了不长头发怎么办 晚上洗了冷水头早上头痛怎么办 头发洗了一天就油了怎么办 米诺地尔搽剂喷了头皮油怎么办 头发可以种植吗如果是秃顶怎么办 前额头发少怎么办如何使头发增多 头发又细又软又少怎么办 宝宝一岁了头发又少又黄怎么办 生完孩子头发掉的厉害怎么办