2017-10-13 51 views
0

我試圖運行以下;Popen可以找到現有的工具

def conn(ad_group): 
    result = Popen(["sudo -S /opt/quest/bin/vastool", "-u host/ attrs 'AD_GROUP_NAME' | grep member"], stdout=PIPE) 
    return result.stdout 

在Python腳本一個RedHat機器上,但我發現FileNotFoundError: [Errno 2] No such file or directory: 'sudo -S /opt/quest/bin/vastool'

我沒有問題,運行在命令行命令(sudo -S /opt/quest/bin/vastool -u host/ attrs 'AD_GROUP_NAME' | grep member)。

我敢肯定,我已經搞亂了功能,但我需要另一套眼睛。

謝謝

回答

1

你需要使整個命令字符串,然後因爲你使用一個管道使用shell=True選項。

result = Popen("sudo -S /opt/quest/bin/vastool -u host/ attrs 'AD_GROUP_NAME' | grep member", stdout=PIPE, shell=True) 
+0

這樣做的工作。謝謝 – Leustad

相關問題