I am here with a issue that : I have a GUI (wxpython), it has spinctrl, the output of spinctrl must be sent to c file, which accept command line argument, so whenever i execute c file using subprocess as it accepts value from GUI the spinctrl value must be sent to it instead of manual typing.
My code is:
ps = "password"
var1 = self.sc1.Getvalue()
var2 = self.sc2.Getvalue()
subprocess.call(['echo xsxsxs | sudo "./license.exe"', str(ps), str(var1), str(var2)],shell = True)
whenever i run this script it doesnot show output/error :(
if i remove echo xsxsxs| sudo from the line 4 and then execute then it show error: "you must be root user","Invalid password", "segmentation fault".
Whenever you use shell=True
to subprocess.Popen
(or one of the convenience wrappers), you should pass a string exactly the way you would type it in your shell, not a list
.
from the docs :
If shell is True, it is recommended to pass args as a string rather than as a sequence.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.