diff --git a/tsshbatch.py b/tsshbatch.py index 06d9c1c..293974b 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.200 2014/12/04 22:32:01 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.201 2014/12/04 22:51:13 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" PROGDATE = "2011-2014" @@ -72,7 +72,7 @@ HOSTNOISE = '[%s]' HOSTLIST = 'Hosts' INDENTWIDTH = 8 -OPTIONSLIST = 'EKG:H:NP:ST:aef:hkl:n:p:tvxy' +OPTIONSLIST = 'EKG:H:NP:ST:aef:hkl:n:p:qtvxy' PADWIDTH = 12 PATHDELIM = ':' PATHSEP = os.sep @@ -91,7 +91,7 @@ USAGE = \ PROGVER + "\n" +\ HOMEPAGE + "\n\n" +\ - "Usage: tsshbatch.py [-EKNSTaehkvxy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' | hostlistfile [command arg ... ]\n" +\ + "Usage: tsshbatch.py [-EKNSTaehkqvxy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' | hostlistfile [command arg ... ]\n" +\ " where,\n" +\ "\n" +\ " -E Write error output to stdout instead of stderr\n" +\ @@ -102,7 +102,7 @@ " -P 'file dest' PUT local file to host dest directory\n" +\ " -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" +\ + " -a Don't abort program after failed file transfers\n" +\ " -e Don't report remote host stderr output\n" +\ " -f cmdfile Read commands from file\n" +\ " -h Display help\n" +\ @@ -110,6 +110,7 @@ " -l logfile Log errors to logfile (Default: /dev/null)\n" +\ " -n name Specify login name\n" +\ " -p pw Specify login password\n" +\ + " -q Quiet mode - produce less noisy output\n" +\ " -t Run in test mode, don't actually execute commands\n" +\ " -v Display extended program version information\n" +\ " -x Turn off test mode (if on) and execute requests\n" +\ @@ -198,6 +199,7 @@ NOISY = False # Print output with extra detail PROMPTUSERNAME = False # Don't use $USER, prompt for username PWORD = "" # Password +QUIET = False # Make output less noisy REDIRSTDERR = False # Redirect stderr to stdout REPORTERR = True # Report stderr output from remote host TESTMODE = True # Run program in test mode, don't actually execute commands @@ -396,7 +398,8 @@ else: ssh.connect(host, username=user, password=pw, allow_agent=False, look_for_keys=False, timeout=TIMEOUT) - PrintReport([host, CONSUCCESS]) + if not QUIET: + PrintReport([host, CONSUCCESS]) # Run all requested commands @@ -439,10 +442,14 @@ ssh.close() raise SystemExit - PrintReport([host + " (stdout)" + " [%s]" % command, "\n"] + stdout.readlines() + ["\n"]) + cmdreport = " [%s]" % command + if QUIET: + cmdreport = "" + + PrintReport([host + " (stdout)" + cmdreport, "\n"] + stdout.readlines() + ["\n"]) if REPORTERR: - PrintReport([host + " (stderr)" + " [%s]" % command, "\n"] + stderr.readlines() + ["\n"], HANDLER=PrintStderr) + PrintReport([host + " (stderr)" + cmdreport, "\n"] + stderr.readlines() + ["\n"], HANDLER=PrintStderr) # Handle aborts @@ -728,6 +735,10 @@ if opt == "-p": PWORD = val + if opt == "-q": + QUIET = True + NOISY = False + if opt == "-t": TESTMODE = True @@ -740,6 +751,7 @@ if opt == "-y": NOISY = True + QUIET = False #####