I use system to launch shell script
return message
call system. return value is 7f00
source code
#include
#include
int main(int argv, char* agrvc)
{
int ret = system("/mnt/sdcard/Hello.sh");
printf("call system. return value is %x", ret);
}
使用execv
可以正確執行到shell script
source code
#include
#include
int main(int arg, char* agrc)
{
//int ret = system("/mnt/sdcard/Hello.sh");
char *argv[]={"bash", "/mnt/sdcard/Hello.sh", NULL};
int ret = execv("/system/bin/bash", argv);
printf("call system. return value is %x", ret);
}
螢幕顯示
This is shellscript. Hello!
此外
run executable file
你可以參考此篇
沒有留言:
張貼留言