I'm attempting to start a process for item in list
using an if statement. The if statement (if condition met) will call a function passing in 2 args. The function then iterates through another list running a subprocess call for each in the list. Now for some reason I'm not getting any output from the subprocess. If I run the same command in the command line it works fine, and it worked fine before I started down the multiprocessing road. Could anyone kindly explain whats going on?
This is how the function is being called.
userlist = (name1, name2, name3)
if condition == True:
for user in userlist:
p = multiprocessing.Process(target=tllocaltF, args=(serverlist, user))
jobs.append(p)
p.start()
this is the function it is calling:
def tllocaltF(domain, user):
#function iterates list of target users locally
print (domain,user) #this prints out the username and domain as expected
print "Targeted Users Found On LocalHost\n"
try:
out = subprocess.check_output(["tasklist", "/V", "/FO", "List", "/FI", "USERNAME eq {0}\\{1}" .format(domain, user)], stderr=subprocess.STDOUT)
users = [item for item in out.split() if domain in item and user in item]
sortedl = set(users)
print sortedl #this is printing set([])
for item in sortedl:
print item
except CalledProcessError as e:
errormessage = e.output
print errormessage
print "\nCompleted"