问题
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