Python OS.System with variables and quotes -


#!/usr/bin/python import os  readline = open('desktops.txt','r')  line in readline:        machinename = line        query = os.system(r'wmic -u corp.fakedomain.com/domainusername%password //'+machinename+ '"select * win32_useraccount localaccount = true"|grep "500|"|cut -d "\\" -f 2|cut -d "|" -f1') 

getting.....

"example: wmic -u [domain/]adminuser%password //host "select * win32_computersystem" sh: syntax error: unterminated quoted string"

if replace \\machinename variable real ip 192.168.1.100 works fine.


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

python - Received unregistered task using Celery with Django -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -