#include<stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include <signal.h> int main()
{
pid_t pid;
char *cmd="bash testshell.sh";
//FILE *fResult=popen("/bin/bash -c testbash.sh","r");
//fResult.close();
pid=fork();
if(pid>)
exit();
else if(pid==)
{ //prctl(PR_SET_PDEATHSIG,SIGKILL);
execl("/bin/bash","/bin/bash","-c",cmd,NULL);
exit();
}
else if(pid<)
{
printf("create faild\n");
exit();
}
return ;
}
testshell.sh文件
date>testshell_log.log
echo "----------------------------">>testshell_log.log
java -jar TestOracle.jar>>testshell_log.log
echo "----------------------------">>testshell_log.log
date>>testshell_log.log>>testshell_log.log
在shell文件中可以执行各种linux命令,也可以写 if else fi 语句