Python OS.System包含变量和引号

时间:2013-08-23 20:21:01

标签: python-2.7

#!/usr/bin/python
import os

readLine = open('desktops.txt','r')

for line in readLine:
       machineName = line
       query = os.system(r'wmic -U corp.fakedomain.com/domainusername%password //'+machineName+ '"Select * from Win32_UserAccount Where LocalAccount = True"|grep "500|"|cut -d "\\" -f 2|cut -d "|" -f1')

获取.....

“示例:wmic -U [domain /] adminuser%password // host”select * from Win32_ComputerSystem“ sh:语法错误:未终止的引用字符串“

如果我用真实的IP 192.168.1.100替换\\ machineName变量,它可以正常工作。

0 个答案:

没有答案
相关问题