我想使用 native C 程序在 android Shell 上运行脚本文件。
我尝试使用 system
函数,但它不起作用。
result = system("sh ./test.sh");
LOGD("result is %d", result);
系统命令返回0表示未成功执行脚本文件。
test.sh 包含
echo "test...."
当此系统调用运行时,Android NDK 应用程序无法打印test....
。
甚至任何脚本都不能使用系统调用来启动。我检查了 10 多个不同的脚本。
test.sh 有 777
权限
如有任何帮助,我们将不胜感激。
最佳答案
“嘘”在哪里?你的'.'是什么?应用程序运行时的当前目录?尝试:
result = system("/system/bin/sh/full/path/to/test.sh");
关于android - 想要在 android NDK 中使用系统调用运行脚本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9885812/