Issue
I want access a device via adb shell commands. The device is connected via USB. Manually I can access that via the terminal with the following commands in the sequence:
cd /Users/xx/xx/
# Change to path./adb shell
# access the add shell- enter password # the terminal expects a input of a password
- run some more commands within the adb shell
What I have tried:
subprocess.run('cd /Users/michael/Documents/platform-tools/ ;./adb shell', shell=True)
it requires me to input the password, for that I wanted to use the input function:
subprocess.run('cd /Users/michael/Documents/platform-tools/ ;./adb shell', shell=True, input=*password*)
When I run that I get the error for the input variable: "TypeError: a bytes-like object is required, not 'str'".
For what I have understood, the 'commands' I send in step 3&4 are not real terminal commands, but inputs for the adb shell.
Can someone tell me, how I can solve that problem and automate this process in python?
Solution
The error asks for a bytes-like object, not a string.
To turn a string literal into a bytes-like object, append b
before the string. Put b
in front of the string that contains the password, something like b"password"
.
Answered By - Ryan Zhang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.