Reputation: 21
For most ADB commands, I understand how to run them on a single line or even when placing them in a shell script, it can easily be done by implementing the secondary command after 'adb shell' but adding " ".
But for some reason nothing works on trying to run this command via a single line or even by putting it in a shell script:
adb shell
task_id=$(dumpsys activity | grep -A2 "(dumpsys activity recents)"| grep '#'| cut -d ' ' -f 7| cut -c 2-); am task lock $task_id
Btw, this is to "screen pin" an application on Android devices.
Upvotes: 2
Views: 4748
Reputation: 45503
You need quotes around your commands :
adb shell '
task_id=$(dumpsys activity | grep -A2 "(dumpsys activity recents)"| grep "#"| cut -d " " -f 7| cut -c 2-)
echo "locking task $task_id"
am task lock $task_id
'
or on one line:
adb shell 'task_id=$(dumpsys activity | grep -A2 "(dumpsys activity recents)"| grep "#"| cut -d " " -f 7| cut -c 2-); am task lock $task_id'
Upvotes: 2