diff --git a/tsshbatch.py b/tsshbatch.py index b3a86a1..85ec47d 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -15,7 +15,7 @@ PROGNAME = "tsshbatch.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -RCSID = "$Id: tsshbatch.py,v 1.130 2012/01/04 19:25:23 tundra Exp $" +RCSID = "$Id: tsshbatch.py,v 1.131 2012/01/04 20:59:16 tundra Exp $" VERSION = RCSID.split()[2] CPRT = "(c)" @@ -154,7 +154,7 @@ # from stdin thereby avoiding fiddling around with ptys. if command.startswith(SUDO): - command = command.replace(SUDO, "%s %s" % (SUDO, SUDOARGS)) + command = command.replace(SUDO, "%s %s" % (SUDO, SUDOARGS), 1) # Run the command @@ -172,7 +172,14 @@ # from sudo telling us to try again or that there was a # command error. - sudonoise = stderr.readline().split(SUDOPROMPT)[1].strip() + sudonoise = stderr.readline().split(SUDOPROMPT) + + if len(sudonoise) > 1: # sudo had problems + sudnoise = sudonoise[1].strip() + + else: # sudo OK + sudonoise = "" + if sudonoise: PrintReport([host, FAILURE, eBADSUDO % sudonoise], HANDLER=PrintStderr) ssh.close()