forked from XXTX-TOP/Linux-kernel_deb_builder
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstallandremove.py
More file actions
27 lines (24 loc) · 877 Bytes
/
installandremove.py
File metadata and controls
27 lines (24 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess
import sys
print('您输入的密码是', sys.argv[1])
print('内核:', sys.argv[2])
print('头文件:', sys.argv[3])
print('安装', sys.argv[4])
echo = subprocess.Popen(['echo',sys.argv[1]],
stdout=subprocess.PIPE,
)
if sys.argv[4] == 'install':
sudo = subprocess.Popen(['sudo','-S','apt','install',sys.argv[2],sys.argv[3],'-y'],
stdin=echo.stdout,
stdout=subprocess.PIPE,
)
else:
sudo = subprocess.Popen(['sudo','-S','apt','purge',sys.argv[2],sys.argv[3],'-y'],
stdin=echo.stdout,
stdout=subprocess.PIPE,
)
for line in iter(sudo.stdout.readline, b''):
line = line.decode('utf-8')
sys.stdout.write(line)
sys.stdout.flush()
sudo.wait()