C语言-调用系统bash关闭后台服务-创新互联
// 说明:
// 1.senseshield服务是 北京深盾 Virbox LM 授权产品的后台服务
// 使用前需要安装virbox用户工具 linux 版
// 2.本示例通过c语言调用linux-bash,手动启停该服务
#include
#include
#include
enum OPERATION{START=1,STOP,STATUS};
int main(int argc,char* argv[])
{
int exit_code = 0;
int i = 0;
int op = 0;
if(argc<= 1)
{
return 0;
}
if (0 == strcmp("start",argv[1]))
{
op = START;
}
else if (0 == strcmp("stop",argv[1]))
{
op = STOP;
}
else if (0 == strcmp("status",argv[1]))
{
op = STATUS;
}
switch(op)
{
case START:
exit_code = system("systemctl start senseshield\n");
break;
case STOP:
exit_code = system("systemctl stop senseshield\n");
break;
case STATUS:
exit_code = system("systemctl status: senseshield\n");
break;
default:
printf("no operation,argument count = %d\n",argc);
break;
}
printf("Running systemctl %s senseshield, exit code = %d\n",argv[1],exit_code);
return 0;
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
当前文章:C语言-调用系统bash关闭后台服务-创新互联
网页链接:http://scyanting.com/article/jidhh.html