Issue
I would like to run the same code on linux and windows. below code works on linux but not on windows!
#!/usr/bin/env python3
import subprocess
def runcmd(cmd,show=True):
print("cmd:" + cmd)
try:
p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
retval = p.communicate()[0]
print(retval)
return retval.decode('utf-8')
except:
print("cmd error:" + cmd)
pass
return ""
def main():
runcmd("adb shell 'find /data/ -type f ! -empty'")
return
if __name__ == "__main__":
main()
The output from windows10:
cmd:adb shell 'find /data/ -type f ! -empty'
b'/system/bin/sh: find /data/ -type f ! -empty: inaccessible or not found\r\n'
Solution
Don't put the entire adb shell command in a single argument. Use:
runcmd("adb shell find /data/ -type f ! -empty")
You may have different versions of adb
on Linux and Windows. The documentation mentions that the way the arguments are processed changed in Android Platform-Tools 23.
Answered By - Barmar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.