python文件:
#!/usr/bin/python
#python.py
print 'python:hello world'
shell文件
#!/usr/bin/sh
#shell.sh
#chmod +x shell.sh
echo shell:hello world
python python.py
cpp文件
//callpython.cpp
#include <iostream>
#include <stdlib.h>
using namespace std;
int main () {
cout << "cpp:hello world" << endl;
system("./shell.sh");
return 0;
}
编译运行:
#g++ callpython.cpp -o callpython
#./callpython
运行结果:
cpp:hello world
shell:hello world
python:hello world