diff --git a/tsshbatch.py b/tsshbatch.py index bee213e..47bd3a4 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.218 2016/01/10 20:18:24 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.219 2016/01/16 16:59:34 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" PROGDATE = "2011-2016" @@ -64,9 +64,10 @@ ABORTING = 'Aborting ...' -BANNERMSG = "%s %s %s On %s At %s" % (PROGNAME, VERSION, '%s', '%s', '%s') -BANNEREND = "Ended" -BANNERSTART = "Started" +BANNERTIME = 'Elapsed Time: %s Seconds' +BANNERMSG = '%s %s %s On %s At %s' % (PROGNAME, VERSION, '%s', '%s', '%s') +BANNEREND = 'Ended' +BANNERSTART = 'Started' COMMENT = '#' COMMANDS = 'Commands' CONSUCCESS = 'SUCCESS: Connection Established' @@ -100,7 +101,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" +\ + " -B Print start and stop statistics\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" +\ @@ -330,7 +331,10 @@ # If requested, print startup banner if BANNERSON: - print BANNERMSG % (BANNERSTART, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S")) + + PrintStdout(BANNERMSG % (BANNERSTART, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S"))) + PrintStdout(BANNERTIME % cloat(time.time() - starttime)) + os._exit(1) @@ -761,6 +765,9 @@ for opt, val in opts: if opt == "-B": + + starttime = time.time() + PrintStdout(BANNERMSG % (BANNERSTART, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S"))) BANNERSON = True if opt == "-E": @@ -840,14 +847,6 @@ ##### -# If requested, print startup banner -##### - -if BANNERSON: - print BANNERMSG % (BANNERSTART, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S")) - - -##### # Intitialize paramiko Logging ##### @@ -1097,6 +1096,8 @@ ##### if BANNERSON: - print BANNERMSG % (BANNEREND, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S")) + + PrintStdout(BANNERMSG % (BANNEREND, time.strftime("%Y-%m-%d"), time.strftime("%H:%M:%S"))) + PrintStdout(BANNERTIME % float(time.time() - starttime))