1

In the bitrise workflow's script step, I added following snippet:

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. But when this workflow is triggered through bitrise, it fails with following logs:

Bitrise Logs

What is the cause of this issue and how to fix it?

Tushar Kathuria
  • 645
  • 2
  • 8
  • 22
  • A common bug is when `grep` matches itself. The ngrep` here is [useless](http://www.iki.fi/era/unix/award.html#grep) anyway; `pidof screenrecord` or if you don't have that `ps | awk '/[s]creenrecord/ { print $2 }' | xargs -r kill` – tripleee Jan 04 '21 at 16:25
  • https://stackoverflow.com/a/15622698/1778421 – Alex P. Jan 04 '21 at 17:37

1 Answers1

1

Most likely this is because awk is not outputting the process 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).

Lino
  • 5,084
  • 3
  • 21
  • 39