Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions xip.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def main():
help='Split outfile files per IP address')
parser.add_option('-d', '--debug', action='store_true', dest='debug',
help='Debug output')
parser.add_option('-b', '--background', action='store_true', dest='background',
help='Run in background (means no output control and no error checking)')
(options, args) = parser.parse_args()

if options.debug:
Expand Down Expand Up @@ -177,12 +179,15 @@ def main():
if debug:
print "+++ Starting: %s" % c
a = shlex.split(c)
p = sub.Popen(a, stdout=sub.PIPE, stderr=sub.PIPE)
output, errors = p.communicate()
e = p.returncode
if debug:
if not options.background:
p = sub.Popen(a, stdout=sub.PIPE, stderr=sub.PIPE)
output, errors = p.communicate()
e = p.returncode
else:
p = sub.Popen(a, stdout=None, stderr=None)
if debug and not options.background:
print "+++ Command RC: %d" % e
if options.output:
if options.output and not options.background:
if options.split:
if debug:
print "+++ Spliting output files per IP address"
Expand All @@ -202,11 +207,11 @@ def main():
f.write("--- Stopped with exit code: %d (%s) ---\n" % (e, time.asctime()))
f.close()
else:
if output:
if not options.background and output:
print output.rstrip()
if errors:
if not options.background and errors:
print errors.rstrip()
if debug and options.output:
if debug and options.output and not options.background:
if options.split:
print "+++ Commands output saved to %s_x_x_x_x" % options.output
else:
Expand Down