JZsdk_FileSystm.c
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include "JZsdk_FileSystm.h"
#include <stdlib.h>
#include <stdbool.h>
/*
* 用于运行指令
*
*/
int JZsdk_RunSystemCmd(char *systemCmd)
{
//FILE *fp;
//printf("JZsdk_RunSystemCmd:%s\n",systemCmd);
// fp = popen(systemCmd, "r");
// if (fp == NULL) {
// return -1;
// }
int status = system(systemCmd);
if (status == -1 || WIFEXITED(status) == false) {
printf("Call %s error, status = %d\n", systemCmd, status);
return -1;
}
if (WEXITSTATUS(status) == 0) {
printf("指令执行成功%s\n",systemCmd);
return 0;
} else {
printf("Exit status is = %d", WEXITSTATUS(status));
return -2;
}
//pclose(fp);
return 0;
}
/*
运行命令 并读取返回值
*/
// FILE* JZsdk_RunSystemCmd_ReturnFilePointer(char *systemCmd)
// {
// FILE *fp;
// fp = popen(systemCmd, "r");
// pclose(fp);
// return fp;
// }
int JZsdk_Socket()
{
}