diff --git a/tsshbatch.py b/tsshbatch.py index 0c26348..98595c3 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -17,7 +17,7 @@ PROGNAME = "tsshbatch.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -CVSID = "$Id: tsshbatch.py,v 1.158 2013/10/24 02:29:17 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.159 2013/10/24 18:53:35 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" @@ -63,9 +63,10 @@ CONSUCCESS = "SUCCESS: Connection Established" FAILURE = "FAILURE: %s" HOSTSEP = ":" +HOSTNOISE = "[%s]" INCLUDE = ".include" INDENTWIDTH = 8 -OPTIONSLIST = "G:H:NP:Sef:hkn:p:v" +OPTIONSLIST = "G:H:NP:Sef:hkn:p:yv" PADWIDTH = 12 PATHSEP = os.sep SEPARATOR = " ---> " @@ -75,10 +76,11 @@ SUDOARGS = '-S -p %s' % SUDOPROMPT SUDOPWHINT = '(Default: login password): ' TRAILER = ": " + USAGE = \ PROGVER + "\n" +\ HOMEPAGE + "\n\n" +\ - "Usage: tsshbatch.py [-NSehkv -G 'file dest' -P 'file dest' -f cmdfile -n name -p pw ] -H 'host ..' | hostlistfile [command arg ... ]\n" +\ + "Usage: tsshbatch.py [-NSehkvy -G 'file dest' -P 'file dest' -f cmdfile -n name -p pw ] -H 'host ..' | hostlistfile [command arg ... ]\n" +\ " where,\n" +\ "\n" +\ " -G 'file dest' GET file on host and write local dest directory\n" +\ @@ -92,7 +94,8 @@ " -k Use key exchange-based authentication\n" +\ " -n name Specify login name\n" +\ " -p pw Specify login password\n" +\ - " -v Display extended program version information\n" + " -v Display extended program version information\n" +\ + " -y Turn on 'noisy' reporting for additional detail\n" ##### @@ -133,6 +136,7 @@ GETSUDOPW = False # Prompt for sudo password HOSTS = [] # List of hosts to target KEYEXCHANGE = False # Do key exchange-based auth? +NOISY = False # Print output with extra detail PROMPTUSERNAME = False # Don't use $USER, prompt for username PWORD = "" # Password REPORTERR = True # Report stderr output from remote host @@ -334,13 +338,20 @@ def PrintReport(results, HANDLER=PrintStdout): - HANDLER(SEPARATOR + results[0] + + hostname = results[0] + HANDLER(SEPARATOR + hostname + TRAILER + (PADWIDTH - len(results[0])) * " " + results[1]) + # Prepend the host name if we've asked for noisy reporting + + hostnoise ="" + if NOISY: + hostnoise = HOSTNOISE % hostname + for r in results[2:]: # Command Results - HANDLER(INDENTWIDTH * " " + r.strip()) + HANDLER(hostnoise + INDENTWIDTH * " " + r.strip()) # End of 'PrintReport()' @@ -466,6 +477,10 @@ PrintStdout(CVSID) sys.exit() + if opt == "-y": + NOISY = True + + ##### # Host & Command Line Command Definition Processing #####