bash iOS 从 Activator 执行 shell 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12223510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:09:17  来源:igfitidea点击:

iOS execute shell script from Activator

bashios5jailbreak

提问by Suchipi

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?

我正在使用越狱的 iOS 设备,我想向 Activator 添加一个操作,该操作执行存储在已知位置的 shell 脚本。有谁知道如何实现这一目标?

回答by Nate

I'm not sure whether or not Activator can run scripts directly, but it certainly can run any appyou 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 execfunction to invoke your script:

我不确定 Activator 是否可以直接运行脚本,但它肯定可以运行您在设备上安装的任何应用程序,无论您喜欢什么操作(例如滑动、摇动、按下按钮)。只需制作一个使用该system()函数的简单应用程序,或一个exec函数来调用您的脚本:

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

Then, setup Activator to run that app.

然后,设置 Activator 以运行该应用程序。

Edit:That will cause a brief flash as the appstarts, 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 setStatemethod this way:

编辑:这将导致应用程序启动时短暂闪烁,然后关闭。这也意味着您正在运行的任何其他应用程序都将关闭(发送到后台)。如果您不喜欢那样,Activator 还允许您构建 SBSettings toggle,然后在用户定义的操作上运行它。请参阅此处以构建 SBSettings 切换。您只需以setState这种方式实现该方法:

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