脚本test.sh shell编程如下:
1 #!/bin/bash
2 echo -e "Hello world! /a /n"
3 exit 0
执行:
./test.sh 执行后打印:Hello world!
echo $? 可以打印它的返回值为:0.
如果使用system :
#include <stdlib.h>
int system(const char *command);
返回值可以这样使用:
while (something) {
int ret = system("foo");
if (WIFSIGNALED(ret) &&
(WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
break;
}