用法

2012-04-06 93 views
0
final="cacls " + "E:/" + "\"" + list1[2] + " " + list1[3] + "\"" + " /p " + str 
pro = subprocess.Popen(final,shell=True, stdin=subprocess.PIPE) 
pro.communicate(bytes("Y\r\n",'utf-8')) 

嘗試設置權限使用Python一個文件夾,但在運行此命令,用戶輸入需要被太即提供用法

它要求ARE YOU SURE(Y/N)和用戶需要輸入「Y」或「N」

以上代碼未設置權限。

這是問題,我之前曾問:

Python code to send command through command line

回答

1

作爲一個聰明的程序員,使用PBS

然後,代碼爲:

from pbs import type as echo# Isn't it echo for Windows? If not, use the correct one 

script = Command("/path/to/cacls ") 
print script(echo("Y"), ("E:/" + "\"" + list1[2] + " " + list1[3] + "\"" + " /p " + str).split())