diff --git a/tsshbatch.py b/tsshbatch.py index 8af433f..28d495f 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.145 2013/10/22 19:06:20 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.146 2013/10/22 22:59:17 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" @@ -59,15 +59,15 @@ COMMENT = "#" +CONSUCCESS = "SUCCESS: Connection Established" FAILURE = "FAILURE: %s" HOSTSEP = ":" INDENTWIDTH = 8 OPTIONSLIST = "G:H:NP:ehkn:p:v" -PADWIDTH = 30 +PADWIDTH = 12 PATHSEP = os.sep SEPARATOR = " ---> " STDIN = "-" -SUCCESS = "SUCCESSFUL CONNECTION" SUDO = 'sudo' SUDOPROMPT = 'READINGSUDOPW' SUDOARGS = '-S -p %s' % SUDOPROMPT @@ -98,7 +98,7 @@ eBADSUDO = "sudo Failed, Check Password Or Command! sudo Error Report: %s" eBADTXRQ = "Bad Transfer Request: %s Must Have Exactly 1 Source And 1 Destination!" eFXERROR = "File Transfer Error: %s" -eNOCONNECT = "Cannot Connect: %s" +eNOCONNECT = "Cannot Connect To %s" eNOHOSTS = "No Hosts Specified!" eNOLOGIN = "Cannot Login! (Login/Password Bad?)" @@ -125,6 +125,7 @@ def PrintStderr(msg, TERMINATOR="\n"): sys.stderr.write(msg + TERMINATOR) + sys.stderr.flush() # End of 'PrintStderr()' @@ -135,6 +136,7 @@ def PrintStdout(msg, TERMINATOR="\n"): sys.stdout.write(msg + TERMINATOR) + sys.stdout.flush() # End of 'PrintStdout()' @@ -215,6 +217,8 @@ else: ssh.connect(host, username=user, password=pw) + PrintReport([host, CONSUCCESS]) + # Run all requested commands for command in commands: @@ -253,10 +257,10 @@ ssh.close() return - PrintReport([host + " (stdout)" + " [%s]" % command, SUCCESS] + stdout.readlines()) - + PrintReport([host + " (stdout)" + " [%s]" % command, "\n"] + stdout.readlines() + ["\n"]) + if REPORTERR: - PrintReport([host + " (stderr)" + " [%s]" % command, ""] + stderr.readlines(), HANDLER=PrintStderr) + PrintReport([host + " (stderr)" + " [%s]" % command, "\n"] + stderr.readlines() + ["\n"], HANDLER=PrintStderr) # Catch authentication problems explicitly @@ -266,7 +270,7 @@ # Everything else is some kind of connection problem except: - PrintReport([host, FAILURE % (eNOCONNECT % sys.exc_info()[1].message)], HANDLER=PrintStderr) + PrintReport([host, FAILURE % (eNOCONNECT % sys.exc_info()[1].strerror)], HANDLER=PrintStderr) ssh.close()