简体   繁体   中英

How to run shell commands on Android phone when connected to a PC?

I need to run ping request on my Android phone using the following format:

 ping google.com | while read pong; do echo " $pong  @$(date)"; done

There are some applications, such as Terminal Emulator which do that. But just in case I'm curious if I can run shell commands on phone using my PC connection, when the phone is connected to my PC?

EDIT: Yes, it works with the command. But for > r.log it needs root. Any suggestions for that?

Enable developer mode on the phone and use adb tool from Android SDK to do that.

I am not sure how powerful adb's shell is, but give it a try.

You can do even more with adb, check its help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM