|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
python subprocess 需要以 1004 用户执行 shell,返回数据
但在linux上运行,报错
result2 <Popen: returncode: None args: ['s', 'h', ' ', ...
不知道subprocess怎么用了?请教大佬,感谢!
- import subprocess,time,os
- def get_shell():
- test1 = "123"
- os.setuid(1004)
- command_test = "sh test.sh "+test1
- print("command_test",command_test)
-
- command_test2 = "sh test2.sh "
- print("command_test2",command_test2)
-
- result2 = subprocess.Popen(args=command_test, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- print("result2",result2)
-
- time.sleep(3)
- result3 = subprocess.Popen(args=command_test2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- print("result3",result3)
- get_shell()
复制代码 |
|