用法

2012-04-06 59 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())