简体   繁体   English

Bash shell 脚本命令在通过 Bitrise 运行时乱序执行

[英]Bash shell script command executes out of order when run through Bitrise

In the bitrise workflow's script step, I added following snippet:在 bitrise 工作流程的脚本步骤中,我添加了以下代码段:

adb shell ps | grep screenrecord | awk ‘{print $2}’ | xargs adb shell kill

Purpose is to kill the process called screenrecord that was started in a previous step and it works fine when I test it on my system.目的是杀死在上一步中启动的名为screenrecord的进程,当我在我的系统上测试它时它工作正常。 But when this workflow is triggered through bitrise, it fails with following logs:但是,当通过 bitrise 触发此工作流时,它会失败并显示以下日志:

比特升日志

What is the cause of this issue and how to fix it?此问题的原因是什么以及如何解决?

Most likely this is because awk is not outputting the process id.这很可能是因为awk没有输出进程 ID。 One possible workaround to try is the following:一种可能的解决方法如下:

adb shell ps | grep screenrecord | sed -E 's/[ ]+/ /g' | cut -d' ' -f2 | xargs adb shell kill

where the awk command has been substituted with sed (to remove the multiple spaces) and a cut one (to get the process id).其中awk命令已替换为sed (以删除多个空格)和一个cut (以获取进程 ID)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Bitrise Bash脚本-找不到命令 - Bitrise bash script - command not found 通过桌面图标运行 bash 脚本时找不到节点命令 - Node command not found when bash script is run through desktop icon 在新的 shell 中运行 bash 命令并在此命令执行后留在新的 shell 中 - run bash command in new shell and stay in new shell after this command executes 通过Shell脚本执行命令时出现Awk语法错误,但是从Linux bash shell执行命令时,该命令运行正常 - Awk syntax error when command is executed through a shell script however the command works fine when executed from Linux bash shell Shell Java 源代码中带有 vimdiff 命令的脚本在 Git 上运行时卡住 bash - Shell script with vimdiff command in Java source code gets stuck when run on Git bash 作为命令运行时将字符串传递给Shell脚本 - Pass string to shell script when run as command 命令在终端中执行良好,而不是在bash脚本中执行 - Command executes fine in terminal, not in a bash script 对执行后台任务的脚本执行bash命令替换 - bash command substitution on a script that executes a background task 如何在bash脚本中的source env shell之后运行命令 - How to run command after source env shell inside bash script 如果命令在 X 秒内为真,则在 bash shell 脚本中运行代码 - if command is true for X seconds run code in bash shell script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM