Приложение называется ltx, и мне нужно запустить его с аргументом -h, например:
Код: Выделить всё
[~]$ ltx -h
Код: Выделить всё
export PATH=$PATH:/home/joe/ltx/bin
Код: Выделить всё
[~]$ ltx -h
[INFO] Startup arguments: [-h]
NAME .....
Я попробовал автоматизировать это с помощью подпроцесса Python, как показано ниже:
Код: Выделить всё
[~]$ python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.run(['ls','-al'],shell=True) --> Test subprocess, working!
>>> subprocess.run(['ltx','-h'],shell=True) --> Now, this is what I want. But error
'ltng-decoder' is not recognized as an internal or external command,
operable program or batch file.
CompletedProcess(args=['ltng-decoder', '-h'], returncode=1)
>>> subprocess.run([r"C:\cygwin64\joe\ltx\bin\ltx","-h"],shell=True) -->Try this too, but still failed
'C:\cygwin64\home\joe\ltx\bin\ltx' is not recognized as an internal or external command,
operable program or batch file.
CompletedProcess(args=['C:\cygwin64\home\joe\ltx\bin\ltx', '-h'], returncode=1)
Подробнее здесь: https://stackoverflow.com/questions/798 ... ernal-comm
Мобильная версия