亚行:从亚行外壳查找PID [英] adb: Find PID from the adb shell

查看:154
本文介绍了亚行:从亚行外壳查找PID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让进程内亚行外壳的PID。所以,我做亚行的shell这让我到Android外壳。现在,如果我是使用普通的外壳,我会用得到PID

I am trying to get the PID of the process INSIDE adb shell. So, I am doing adb shell which gets me to the android shell. Now, if I were to get the PID using a regular shell I would use

adb shell ps | grep android.process.acore | sed 's/\s\s*/ /g' | cut -d ' ' -f 2

adb shell ps | grep android.process.acore | awk '{ print $2 }'

我得到的PID(数字号 - PS的第二场| grep的android.process.acore )的输出

但是,如果我运行Android壳内上面的命令(后做亚行外壳),我得到 /系统/ bin / sh的命令:sed :分别是未找到错误:未找到和 /系统/ bin / sh的:AWK。这意味着,这些命令不可用ADB壳体内。然而,grep的工作。

However, if I run the above commands inside android shell(after doing adb shell), I get /system/bin/sh: sed: not found and /system/bin/sh: awk: not found errors respectively. Which means, these commands are not available inside adb shell. However, grep works.

的输出 PS | grep的android.process.acore 亚行外壳是:

XXX_x21   11826 441   502296 39028 ffffffff 4010ff6c S android.process.acore

我要寻找数11826。
我怎样才能提取它里面亚行外壳

另外,请大家帮帮忙,如果有一个直接的方式来获得PID亚行外壳内。

Also, please help if there is a direct way to get the PID inside the adb shell.

问候,
Rumit

Regards, Rumit

推荐答案

不知道,如果你可以直接得到PID但是你可以尝试以下

Not sure if you can get the PID directly however you can try the following


set `ps |grep android.process.acore`
echo $2

这已经在ps命令的输出设置成变量$ 1,$ 2,$ 3等的PID值是$ 2的影响

This has the affect of setting the output of the ps command into variables $1, $2, $3 etc. The PID value is in $2

这篇关于亚行:从亚行外壳查找PID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆