diff --git a/tsshbatch.py b/tsshbatch.py index 87b2ea7..f4fd958 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.216 2016/01/10 19:38:29 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.217 2016/01/10 20:17:43 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" PROGDATE = "2011-2016" @@ -64,6 +64,9 @@ ABORTING = 'Aborting ...' +BANNERMSG = "%s %s %s On %s At %s" % (PROGNAME, VERSION, '%s', '%s', '%s') +BANNEREND = "Ended" +BANNERSTART = "Started" COMMENT = '#' COMMANDS = 'Commands' CONSUCCESS = 'SUCCESS: Connection Established' @@ -75,7 +78,7 @@ HOSTNOISE = '[%s]' HOSTLIST = 'Hosts' INDENTWIDTH = 8 -OPTIONSLIST = 'EKG:H:NP:ST:abef:hkl:n:p:qstvxy' +OPTIONSLIST = 'BEKG:H:NP:ST:abef:hkl:n:p:qstvxy' PADWIDTH = 12 PATHDELIM = ':' PATHSEP = os.sep @@ -97,6 +100,7 @@ "Usage: tsshbatch.py [-EKNSTaehkqstvy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' | hostlistfile [command arg ... ]\n" +\ " where,\n" +\ "\n" +\ + " -B Print start and stop banners\n" +\ " -E Write error output to stdout instead of stderr\n" +\ " -K Force password prompting - Overrides previous -k\n" +\ " -G 'file dest' GET file on host and write local dest directory\n" +\ @@ -199,6 +203,7 @@ ABORTBADSUDO = True # Abort after a sudo promotion error ABORTONFXERROR = True # Abort after a file transfer error +BANNERSON = False # Print start/stop banner info GETSUDOPW = False # Prompt for sudo password Hosts = [] # List of hosts to target KEYEXCHANGE = False # Do key exchange-based auth? @@ -322,6 +327,11 @@ if msg: PrintStderr(msg) + # If requested, print startup banner + + if BANNERSON: + print BANNERMSG % (BANNERSTART, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S")) + os._exit(1) # End Of 'ErrorExit()' @@ -751,6 +761,9 @@ for opt, val in opts: + if opt == "-B": + BANNERSON = True + if opt == "-E": REDIRSTDERR = True @@ -828,6 +841,14 @@ ##### +# If requested, print startup banner +##### + +if BANNERSON: + print BANNERMSG % (BANNERSTART, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S")) + + +##### # Intitialize paramiko Logging ##### @@ -1071,3 +1092,12 @@ if Commands: HostCommands(host, UNAME, PWORD, SUDOPW, Commands) + +##### +# If requested, print startup banner +##### + +if BANNERSON: + print BANNERMSG % (BANNEREND, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S")) + +