python 调用adb shell

目录

python调用 bat,启动新窗口,但是不能自动在进入shell 后执行提前设置的操作。

python启动cmd新窗口,但是不能自动在进入shell 后执行提前设置的操作。


python调用 bat,启动新窗口,但是不能自动在进入shell 后执行提前设置的操作。

   bat_file_path = 'adb_call.bat'
    with open(bat_file_path, 'w') as file:
        file.write(f'adb -s {ip} shell\n')

        # file.write(f'tail -fn 200 /sdcard/aaa.txt\n')


    # call_adb(push_str,if_pring=True)
    print('push end')
    subprocess.Popen(['cmd', '/c', 'start', 'cmd', '/k', bat_file_path])

python启动cmd新窗口,但是不能自动在进入shell 后执行提前设置的操作。

def look_log(ip):
    log_path=f"/sdcard/sandstar/app/{log_name}"
    adb_str = f"adb connect {ip}"
    # fn='-f'
    fn='-fn 200'
    res = call_adb(adb_str)

    command =f'adb -s {ip} shell tail -fn 200 /sdcard/2023-09-16.txt'
    # command =f'adb -s {ip} shell'
    subprocess.run(['cmd', '/c', 'start', 'cmd', '/k', command])

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/132940152