#!/usr/bin/python
import os
readLine = open('desktops.txt','r')
for line in readLine:
machineName = line
query = os.system('wmic -U corp.fakedomain.com/domainusername%password //192.168.1.100 "Select * from Win32_UserAccount Where LocalAccount = True"|grep "500|"|cut -d "\\" -f 2|cut -d "|" -f1')
我收到以下错误...
myhostname:〜#。/ getLocalAdminNames.py sh:语法错误:未终止的带引号的字符串 sh:语法错误:未终止的带引号的字符串 sh:语法错误:未终止的带引号的字符串 sh:语法错误:未终止的带引号的字符串 sh:语法错误:未终止的带引号的字符串
然后在我解决错误后,我想用机器名变量替换IP。
非常感谢任何帮助。
答案 0 :(得分:0)
你应该逃避你的反斜杠。将\\
替换为\\\\
:
os.system('wmic -U corp.fakedomain.com/domainusername%password //192.168.1.100 "Select * from Win32_UserAccount Where LocalAccount = True"|grep "500|"|cut -d "\\\\" -f 2|cut -d "|" -f1')
或者,通过添加raw
前缀:
r
os.system(r'wmic -U corp.fakedomain.com/domainusername%password //192.168.1.100 "Select * from Win32_UserAccount Where LocalAccount = True"|grep "500|"|cut -d "\\" -f 2|cut -d "|" -f1')
另见: