Skip to content

Commit

Permalink
Print error messages to stderr, not stdout.
Browse files Browse the repository at this point in the history
  • Loading branch information
hlein committed Feb 9, 2016
1 parent ae702fc commit cd43e08
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dscomputers.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def processComputer(computer):

# Setting up the environment
if not checkfile(sys.argv[1]):
print("\n[!] Error! datatable cannot be found!")
sys.stderr.write("\n[!] Error! datatable cannot be found!\n")
sys.exit(1)
wd = ensure_dir(sys.argv[2])

Expand Down
2 changes: 1 addition & 1 deletion dsdeletedobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
optid += 1

if not checkfile(sys.argv[1]):
print("\n[!] Error! datatable cannot be found!")
sys.stderr.write("\n[!] Error! datatable cannot be found!\n")
sys.exit(1)
wd = ensure_dir(sys.argv[2])

Expand Down
4 changes: 2 additions & 2 deletions dsgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ def usage():

# Setting up the environment
if not checkfile(sys.argv[1]):
print("\n[!] Error! datatable cannot be found!")
sys.stderr.write("\n[!] Error! datatable cannot be found!\n")
sys.exit(1)
if not checkfile(sys.argv[2]):
print("\n[!] Error! linktable cannot be found!")
sys.stderr.write("\n[!] Error! linktable cannot be found!\n")
sys.exit(1)
wd = ensure_dir(sys.argv[3])

Expand Down
8 changes: 4 additions & 4 deletions dskeytab.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def usage():

# Setting up the environment
if not checkfile(sys.argv[1]):
print("\n[!] Error! datatable cannot be found!")
sys.stderr.write("\n[!] Error! datatable cannot be found!\n")
sys.exit(1)
if not checkfile(sys.argv[2]):
print("\n[!] Error! linktable cannot be found!")
sys.stderr.write("\n[!] Error! linktable cannot be found!\n")
sys.exit(1)
wd = ensure_dir(sys.argv[4])

Expand Down Expand Up @@ -231,13 +231,13 @@ def dsPackKeytabEntry(realm, SAMAccountName, nameType, timestamp, keyVersionNumb
utype = -1
utype = dsGetTypeIdByTypeName(db, "Person")
if utype == -1:
print "Unable to get type id for Person"
sys.stderr.write("Unable to get type id for Person\n")
sys.exit(1)

ctype = -1
ctype = dsGetTypeIdByTypeName(db, "Computer")
if ctype == -1:
print "Unable to get type id for Computer"
sys.stderr.write("Unable to get type id for Computer\n")
sys.exit(1)

defaultRealm = dsGetMachineDomain()
Expand Down
2 changes: 1 addition & 1 deletion dstimeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def usage():

# Check the datatable
if not checkfile(sys.argv[1]):
print("\n[!] Error! datatable cannot be found!")
sys.stderr.write("\n[!] Error! datatable cannot be found!\n")
sys.exit(1)

# Check the workdir
Expand Down
8 changes: 4 additions & 4 deletions dsusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,21 @@ def processUser(user):
optid += 1

if (pwdump or pwhdump) and syshive == "":
print("\n[!] Error! syshive not specified!")
sys.stderr.write("\n[!] Error! syshive not specified!\n")
usage()
sys.exit(1)

if suppcreddump == True and syshive == "":
print("\n[!] Error! syshive not specified!")
sys.stderr.write("\n[!] Error! syshive not specified!\n")
usage()
sys.exit(1)

# Setting up the environment
if not checkfile(sys.argv[1]):
print("\n[!] Error! datatable cannot be found!")
sys.stderr.write("\n[!] Error! datatable cannot be found!\n")
sys.exit(1)
if not checkfile(sys.argv[2]):
print("\n[!] Error! linktable cannot be found!")
sys.stderr.write("\n[!] Error! linktable cannot be found!\n")
sys.exit(1)
wd = ensure_dir(sys.argv[3])

Expand Down
4 changes: 2 additions & 2 deletions ntds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
debug = True

def simple_exception(type, value, traceback):
print "[!] Error!", value
sys.stderr.write("[!] Error!", value, "\n")
sys.exit(1)

if debug == False:
sys.excepthook = simple_exception
sys.excepthook = simple_exception

0 comments on commit cd43e08

Please sign in to comment.