Skip to content

Instantly share code, notes, and snippets.

@Node0
Last active February 5, 2016 05:27
Show Gist options
  • Save Node0/52559302d1083625b4cc to your computer and use it in GitHub Desktop.
Save Node0/52559302d1083625b4cc to your computer and use it in GitHub Desktop.
business@node-0.com
#!/usr/bin/env python
import os;
import sys;
def printf(fmt, *varargs):
sys.stdout.write(fmt % varargs)
domainListFile = "/root/acctWorkFiles/domainList.txt";
userListFile = "/root/acctWorkFiles/userList.txt";
passwordListFile = "/root/acctWorkFiles/passwordList.txt";
dlHandle = open(domainListFile);
ulHandle = open(userListFile);
plHandle = open(passwordListFile);
domainList = [domListItem.rstrip('\n') for domListItem in dlHandle];
userList = [usrListItem.rstrip('\n') for usrListItem in ulHandle];
passwordList = [passListItem.rstrip('\n') for passListItem in plHandle];
dlHandle.close(); ulHandle.close(); plHandle.close();
for i in range(len(domainList)):
printf("%s:", domainList[i]);
printf("%s:", userList[i]);
printf("%s\n", passwordList[i]);
@MrHamel
Copy link

MrHamel commented Dec 20, 2015

Bored at the NOC, so code...

#!/usr/bin/env python

with open("/root/acctWorkFiles/domainList.txt", "r") as domainListFile, open("/root/acctWorkFiles/userList.txt", "r") as userListFile, open("/root/acctWorkFiles/passwordList.txt", "r") as passwordListFile:
    domainList = domainListFile.read().splitlines()
    userList = userListFile.read().splitlines()
    passwordList = passwordListFile.read().splitlines()

for i in range(len(domainList)): print("%s - %s - %s", % (domainList[i], userList[i], passwordList[i]))

@Node0
Copy link
Author

Node0 commented Dec 23, 2015

Nice, were you going for number of lines saved?
I actually wrote arrayLoops.py as an excercise in
how to write self documenting code i.e. Make things obvious
to a non-python programmer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment