【问题标题】:How to start a script in termux from an app如何从应用程序在 termux 中启动脚本
【发布时间】:2017-10-16 14:54:36
【问题描述】:

我需要在我的 android 平板电脑上的 termux 环境中从其他 android 应用程序启动一个脚本。我认为应该有两种可能。

  1. 在 termunx 中设置某种启动脚本(如 bash shell 中的 ~/.bashrc)并从其他应用程序启动 termux
  2. 使用脚本名称作为参数从其他应用调用 termux,以便 termux 立即执行该脚本。

我不知道如何实现这两种可能性。 有谁知道如何完成它,也许是第三种方法,我到目前为止还没有想到?

【问题讨论】:

标签: android termux


【解决方案1】:

我只见树木不见森林。答案正是我第一个建议的方式。我没有意识到,bash 是 termux 中的默认 shell。所以只有一个 .bashrc .profile .bash_profile 可以完成这项工作。

【讨论】:

  • 想详细说明你是如何解决这个问题的?
  • 只需在你的thermux 中的主目录。像任何其他 bash 脚本一样编辑它。如果.bashrc 存在且可执行(chmod u+x .bashrc),则在thermux 启动后直接执行。在脚本中,您可以设置环境变量(export TEST=test)、执行其他程序(test_program option1 option2)或执行其他一些 bash 魔术。希望这会有所帮助
猜你喜欢
  • 2022-11-08
  • 1970-01-01
  • 1970-01-01
  • 2012-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多