[英]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.