我正在编写一个为用户安装命令行界面的脚本。
proc = Popen("sudo -S apt-get install vim".split(), stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
# Popen only accepts byte-arrays so you must encode the string
output = proc.communicate(password.encode())
stdoutput = (output)[0].decode('utf-8')
输出:
Installing Vim...|Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
vim-runtime
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-runtime
0 upgraded, 2 newly installed, 0 to remove and 5 not upgraded.
Need to get 7,111 kB of archives.
After this operation, 34.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
如您所见,软件包的安装停止Do you want to continue?,并且由于某种原因,安装被中止。
我如何y在这个阶段使用传递 a Popen()?
我已经使用传递密码communicate(),但没有进行多次输入。
qq_遁去的一_1
相关分类