reading input interactively from "adb shell <command>" -
when run adb shell "read var?prompt" on computer, prompt, nothing type seems sent remote shell (i have press ctrl+c kill adb shell process). works when use interactive shell, looks adb shell <command> maps stdout , not stdin.
is there workaround can use send input non-interactive command?
i know question has been here quite time, found myself same problem (different use case though) , find suitable solution specific case.
if solution suggested in other question not work (for me did not), following analysis got me own answer.
if browse through source code of adb (i used this one answer) see in commandline.cpp implementation different case "adb shell" depending on number of arguments (either "shell" or "shell [args]"). following code fragment source file shows (within function adb_commandline):
//[...] if (!strcmp(argv[0], "shell") || !strcmp(argv[0], "hell")) { char h = (argv[0][0] == 'h'); if (h) { printf("\x1b[41;33m"); fflush(stdout); } if (argc < 2) { d("starting interactive shell\n"); r = interactive_shell(); if (h) { printf("\x1b[0m"); fflush(stdout); } return r; } // non-interactive shell. here arguments after "shell" parsed. // [...] } that means adb runs interactively when command line "adb shell", , non-interactively when having more arguments.
therefore, need change source code make adb treat "shell" interactive, regardless of amount of arguments after "shell".
i hope helped approach solution use case.
Comments
Post a Comment