How to execute the “help” Linux command on Android?

北战南征 提交于 2019-12-23 16:13:26

问题


I would like to run a command like am -help and get usage information for that command. However, the -help parameter does not seem to work on the Process Runtime. How to make this work?

cmd1[0] = "/system/bin/sh";
cmd1[1] = "-c";
cmd1[2] = "/system/bin/am -help"  //I want to do sth like this
Process process = Runtime.getRuntime().exec(cmd1);

The command works without the -help. Is there any way of getting Android Shell commmands' usage information and/or syntaxes? Note that if I don't send am -help and just send the command am then it automatically returns usage information for that command. Is there any way to invoke that response in any other way?


回答1:


#!/system/bin/sh
curl -s http://man.he.net/?topic=$1\&section=all | tail -n +10 | head -n -9

save this in xbin (lets call it hlp.sh) then just hlp.sh cat, you will have help documentation for cat .. you just need install curl first & also need internet connection ..




回答2:


I hope I haven't misunderstood what it is you are trying to do. But have you heard of the man command? For example if you wanted to run gparted you could enter man gparted and get the documentation on the program. --help is not as thorough as the information you'll find in a man page.

You do not need to root to use the man command.

EDIT: My bad. https://android.stackexchange.com/questions/2149/where-can-i-find-documentation-for-shell-commands I don't think you can use the man command on Android. That sucks. Check that link though, there are some interesting answers.



来源:https://stackoverflow.com/questions/41498651/how-to-execute-the-help-linux-command-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!