diff --git a/tsshbatch.py b/tsshbatch.py index 99199c2..87b2ea7 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.215 2016/01/10 18:48:23 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.216 2016/01/10 19:38:29 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" PROGDATE = "2011-2016" @@ -75,7 +75,7 @@ HOSTNOISE = '[%s]' HOSTLIST = 'Hosts' INDENTWIDTH = 8 -OPTIONSLIST = 'EKG:H:NP:ST:aef:hkl:n:p:qstvxy' +OPTIONSLIST = 'EKG:H:NP:ST:abef:hkl:n:p:qstvxy' PADWIDTH = 12 PATHDELIM = ':' PATHSEP = os.sep @@ -106,6 +106,7 @@ " -S Force prompting for sudo password\n" +\ " -T seconds Timeout for ssh connection attempts (Default: 15 sec)\n" +\ " -a Don't abort program after failed file transfers\n" +\ + " -b Don't abort program after failed sudo command\n" +\ " -e Don't report remote host stderr output\n" +\ " -f cmdfile Read commands from file\n" +\ " -h Display help\n" +\ @@ -196,6 +197,7 @@ # Options That Can Be Overriden By User #### +ABORTBADSUDO = True # Abort after a sudo promotion error ABORTONFXERROR = True # Abort after a file transfer error GETSUDOPW = False # Prompt for sudo password Hosts = [] # List of hosts to target @@ -474,9 +476,17 @@ sudonoise = " ".join(stderr.readline().split(SUDOPROMPT)).strip() if sudonoise: # sudo had problems + PrintReport([host + " [%s]" % command, eCMDFAILURE % (eBADSUDO % sudonoise)] + ["\n"], HANDLER=PrintStderr) - ssh.close() - raise SystemExit + + # Abort program on sudo failure. This is default behavior + # but can be overriden on the command line. + + if ABORTBADSUDO: + ssh.close() + raise SystemExit + else: + break cmdreport = " [%s]" % command if NOISELEVEL == QUIET: @@ -772,6 +782,9 @@ if opt == "-a": ABORTONFXERROR = False + if opt == "-b": + ABORTBADSUDO = False + if opt == "-e": REPORTERR = False