从 iPhone 应用程序运行 BASH 脚本?

发布于 2024-07-25 07:33:51 字数 239 浏览 4 评论 0原文

基本上我想知道是否可以从 iPhone 应用程序运行控制台脚本 (.sh)。 该脚本的编写目的是从我设置的存储库下载程序,重新启动,然后在设定的时间后删除该程序并再次重新启动,因此它需要root权限,并且是交互式的,因为用户可以设置程序将运行多长时间被保存。 我编写了 bash 脚本,从移动终端调用时它工作正常,但是有什么方法可以在(越狱的)应用程序中执行此操作(不使用移动终端/SSH/Bossprefs)? 或者是否有更好的方法来实现这一目标? 谢谢

Basically I am wondering if it is possible to run a console script (.sh) from an iPhone App. The script is written to download a program from a repository that I set up, respring, then after a set time delete the program and respring again, so it needs root privileges, and is interactive in that the user can set how long the program will be kept. I have the bash script written, and it works fine when called from mobile terminal, but is there any way to do this from within a (jailbroken) app (without using mobile terminal / SSH / Bossprefs)? Or is there an overall better way to achieve this?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

昨迟人 2024-08-01 07:33:51

Jasarien 就在这里,它受到很大的限制,而且我们都知道所有应用程序都是沙盒的。 但这并非不可能,因为 Objective-C 只是基于 C 构建的,您可以使用它

system("ls");

来执行基本的 ls 命令,并且如果您查看 gdb 输出,它就可以工作。 不过,您还可以使用 popen 将流传输到应用程序以处理数据。

Jasarien is right here it is pretty resticted and as we all know that all apps are sandboxed. But it is not impossible since Objective-C is just build on C you can use

system("ls");

to execute a basic ls command and it works if you look in your gdb output. Altho you can also use popen to get the streams to app to work with the data.

各自安好 2024-08-01 07:33:51

由于您使用的是越狱手机,因此您几乎不受限制。 不过 iPhone API 中是否有任何允许脚本执行的东西是另一回事。 此外,您使用的任何内容都将不受支持,并且可能会更改、停止工作或在软件更新中被删除。

另外,您可能已经知道这一点,或者不关心,但如果您开始运行 BASH 脚本,您将无法通过 Apple 对 App Store 的审核流程。 禁止解释代码。

Since you're working with a Jailbroken phone, you're pretty much unrestricted. Whether or not there's anything in the iPhone APIs that allows for script execution is another matter though. Also anything you do use will be unsupported, and is likely to change, stop working or be removed in a software update.

Also, you probably already know this, or don't care, but you won't get past Apple's review process for the App Store if you start running BASH scripts. Interpreted code is forbidden.

顾北清歌寒 2024-08-01 07:33:51

我会查找如何在 OSX 上执行此操作,很可能在 iPhone 上也是如此,但您可能找不到任何有关它的 iPhone 特定文档,因为它在“普通”iPhone 上是不允许的(即没有越狱)

I would look up how to do it on OSX, chances are that'll be how it's done on the iPhone, but you probably won't find any iPhone specific documentation about it because it's not allowed on a "normal" iphone (one that is not jailbroken)

笨死的猪 2024-08-01 07:33:51

如果您想从 shell 获取输出和错误消息,您可能会考虑使用 NSTask。

something you may consider is using NSTask if you want to get output and error messages from the shell.

茶色山野 2024-08-01 07:33:51

实际上

系统('ls /'); 给出更好的结果 system('ls');

Actualy

system('ls /'); gives a better result as system('ls');

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文