gpt4 book ai didi

android - 如何从另一个 shell 脚本将一个 shell 脚本作为进程启动

转载 作者:太空宇宙 更新时间:2023-11-04 04:59:40 24 4
gpt4 key购买 nike

我想从主机上运行的 script1.sh 执行此操作

#!/bin/sh

# adb shell "sh /sdcard/script2.sh &"

script2.sh 位于 Android 设备上的/sdcard/文件夹内。

我希望 script2.sh 继续在 Android 上运行。 script2.sh 有无限循环。但上面的命令不起作用。 script1.sh 退出后 script2.sh 就会停止。

我也尝试过

# adb shell "exec sh /sdcard/script2.sh &"

但这也行不通。

最佳答案

在父 shell 脚本中,提取子进程 script2.sh 的 pid。然后使用 wait 系统命令等待其完成。

wait <PID>

引用此link了解更多详情。

关于android - 如何从另一个 shell 脚本将一个 shell 脚本作为进程启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36854686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com