iOS execute shell script from Activator

醉酒当歌 提交于 2020-01-02 09:39:06

问题


I am using a jailbroken iOS device, and I want to add an action to Activator that executes a shell script stored in a known location. Does anyone know how to achieve this?


回答1:


I'm not sure whether or not Activator can run scripts directly, but it certainly can run any app you install on your device, with whatever action (e.g. swipe, shake, button press) you like. Just make a simple app that uses the system() function, or an exec function to invoke your script:

int main(int argc, char *argv[])
{
    int returnCode = system("/bin/myscript.sh arg1 arg2");
    return 0;
}

Then, setup Activator to run that app.

Edit: That will cause a brief flash as the app starts, and then closes. This also means that any other app that you're running will be closed (sent to the background). If you don't like that, Activator also lets you build a SBSettings toggle, and then run it on a user-defined action. See here for building a SBSettings toggle. You would just implement the setState method this way:

void setState(BOOL Enabled) 
{
    int returnCode = system("/bin/myscript.sh arg1 arg2");
}


来源:https://stackoverflow.com/questions/12223510/ios-execute-shell-script-from-activator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!