• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Linux-wang
博客园    首页    新随笔    联系   管理    订阅  订阅
Linux System命令

http://blog.csdn.net/cheyo/article/details/6595955

 1 #include <stdio.h>  
 2 #include <stdlib.h>  
 3 #include <sys/wait.h>  
 4 #include <sys/types.h>  
 5   
 6 int main()  
 7 {  
 8     pid_t status;  
 9   
10     status = system("./test.sh");  
11     if (-1 == status)  
12     {  
13         printf("system error!");  
14     }  
15     else  
16     {  
17         printf("exit status value = [0x%x]\n", status);  
18         if (WIFEXITED(status))  
19         {  
20             if (0 == WEXITSTATUS(status))  
21             {  
22                 printf("run shell script successfully.\n");  
23             }  
24             else  
25             {  
26                 printf("run shell script fail, script exit code: %d\n", WEXITSTATUS(status));  
27             }  
28         }  
29         else  
30         {  
31             printf("exit status = [%d]\n", WEXITSTATUS(status));  
32         }  
33     }  
34   
35     return 0;  
36 }  
37 
38 status

 

posted on 2018-05-07 10:30  SmallMosquito  阅读(293)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3