`~` source: [issues/51#issuecomment-4431](https://gitea.lemnoslife.com/Benjamin_Loison/adb/issues/51#issuecomment-4431) does not help.
DuckDuckGo search *adb escape write text*.
[The Stack Overflow question 25791423](https://stackoverflow.com/q/25791423) raises this concern, but answers may not be exhaustive.
Would help [Benjamin_Loison/Backup_Android_apps/issues/50](https://codeberg.org/Benjamin_Loison/Backup_Android_apps/issues/50).
importsubprocessimportpyperclipclipboard=pyperclip.paste()subprocess.check_output(f'adb shell input text {clipboard}',shell=True)
Output:
Exception occurred while executing 'text':
java.lang.IllegalArgumentException: Argument expected after "text"
at com.android.modules.utils.BasicShellCommandHandler.getNextArgRequired(BasicShellCommandHandler.java:295)
at com.android.server.input.InputShellCommand.runText(InputShellCommand.java:365)
at com.android.server.input.InputShellCommand.onCommand(InputShellCommand.java:290)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.input.InputManagerService.onShellCommand(InputManagerService.java:3887)
at android.os.Binder.shellCommand(Binder.java:1151)
at android.os.Binder.onTransact(Binder.java:953)
at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:1576)
at android.os.Binder.execTransactInternal(Binder.java:1426)
at android.os.Binder.execTransact(Binder.java:1365)
/bin/sh: 2: Syntax error: word unexpected (expecting ")")
Traceback (most recent call last):
File "<tmp 5>", line 6, in <module>
subprocess.check_output(f'adb shell input text {clipboard}', shell = True)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 472, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs).stdout
^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 577, in run
raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'adb shell input text
subprocess.check_output(f'adb shell input text {shlex.quote(clipboard)}', shell = True)' returned non-zero exit status 2.
With *(* in `clipboard`:
<details>
<summary>Python script:</summary>
```python
import subprocess
import pyperclip
clipboard = pyperclip.paste()
subprocess.check_output(f'adb shell input text {clipboard}', shell = True)
```
</details>
<details>
<summary>Output:</summary>
```
Exception occurred while executing 'text':
java.lang.IllegalArgumentException: Argument expected after "text"
at com.android.modules.utils.BasicShellCommandHandler.getNextArgRequired(BasicShellCommandHandler.java:295)
at com.android.server.input.InputShellCommand.runText(InputShellCommand.java:365)
at com.android.server.input.InputShellCommand.onCommand(InputShellCommand.java:290)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.input.InputManagerService.onShellCommand(InputManagerService.java:3887)
at android.os.Binder.shellCommand(Binder.java:1151)
at android.os.Binder.onTransact(Binder.java:953)
at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:1576)
at android.os.Binder.execTransactInternal(Binder.java:1426)
at android.os.Binder.execTransact(Binder.java:1365)
/bin/sh: 2: Syntax error: word unexpected (expecting ")")
Traceback (most recent call last):
File "<tmp 5>", line 6, in <module>
subprocess.check_output(f'adb shell input text {clipboard}', shell = True)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 472, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs).stdout
^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 577, in run
raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'adb shell input text
subprocess.check_output(f'adb shell input text {shlex.quote(clipboard)}', shell = True)' returned non-zero exit status 2.
```
</details>
importshlexsubprocess.check_output(f'adb shell input text {shlex.quote(clipboard)}',shell=True)
Output:
/system/bin/sh: import: inaccessible or not found
Traceback (most recent call last):
File "<tmp 5>", line 4, in <module>
subprocess.check_output(f'adb shell input text {shlex.quote(clipboard)}', shell = True)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 472, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs).stdout
^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 577, in run
raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'adb shell input text 'import subprocess
import pyperclip
'' returned non-zero exit status 127.
```python
import shlex
subprocess.check_output(f'adb shell input text {shlex.quote(clipboard)}', shell = True)
```
<details>
<summary>Output:</summary>
```
/system/bin/sh: import: inaccessible or not found
Traceback (most recent call last):
File "<tmp 5>", line 4, in <module>
subprocess.check_output(f'adb shell input text {shlex.quote(clipboard)}', shell = True)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 472, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs).stdout
^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 577, in run
raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'adb shell input text 'import subprocess
import pyperclip
'' returned non-zero exit status 127.
```
</details>
`%s` replaces `s` with a space, while `%a` works fine for instance...
Would help [Benjamin_Loison/Backup_Android_apps/issues/60](https://codeberg.org/Benjamin_Loison/Backup_Android_apps/issues/60).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
~source: issues/51#issuecomment-4431 does not help.DuckDuckGo search adb escape write text.
The Stack Overflow question 25791423 raises this concern, but answers may not be exhaustive.
Would help Benjamin_Loison/Backup_Android_apps/issues/50.
seems to work fine.
With ( in
clipboard:Python script:
Output:
Output:
Output:
Related to Benjamin_Loison/virt-manager/issues/9.
%sreplacesswith a space, while%aworks fine for instance...Would help Benjamin_Loison/Backup_Android_apps/issues/60.
Writing character by character deserves working and is not that slow.
https://hg-edge.mozilla.org/mozilla-central/file/tip/testing/mozbase/rust/mozdevice/src/shell.rs
may help.