我有命令:
proc = subprocess.Popen(["sshpass -p root ssh root@(IP_ADRESS) 'cd
/home/pi/reed && python reed.py'"], shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, )
shell=True
很危险,所以我想避开它并使用shell=False
。
任何提示?
答案 0 :(得分:0)
您应该拆分命令。像这样:
proc = subprocess.Popen("sshpass -p root ssh root@(IP_ADRESS) 'cd /home/pi/reed && python reed.py'".split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, )
答案 1 :(得分:0)
也许这个?
proc = subprocess.Popen(["sshpass", "-p", "root", "ssh", "root@(IP_ADRESS)", "cd /home/pi/reed && python reed.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, )