linux高编进程------system函数使用

解释器就是脚本文件

#include <unistd.h>
/*************************
 *功能:执行一个脚本命令
 *参数:command:/bin/sh -c command下的命令
 *返回值:1.fork阶段失败返回-1
          2.调用/bin/sh,如果调用失败或非正常运行,原因被写到status中
          3.如果shell脚本正常结束,将shell返回值填写到status的8-15bit中
 * **********************/
int system(const char *command);

eg:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void)
{

    system("date+%s > /tmp/out");
    exit(0);
}
原文地址:https://www.cnblogs.com/muzihuan/p/5291821.html