diff --git a/TODO b/TODO index 27fddb1..ebf0ea6 100644 --- a/TODO +++ b/TODO @@ -1,50 +1,67 @@ [NEW] -- Multiple hostfiles can now be passed via the -i option. The - argument can be the name of a single file or a quoted list of files. - The option can appear on the command line multiple times. - -H and -i can be used together to create custom host lists. + - Multiple hostfiles can now be passed via the -i option. The + argument can be the name of a single file or a quoted list of + files. The option can appear on the command line multiple times. + -H and -i can be used together to create custom host lists. -- The -L option will list all (if any) host- and command files found on - their respective search paths. + - The -L option will list all (if any) host- and command files found + on their respective search paths. + + - The -W option will write out the inventory of hosts that would be + processed if you actually executed the program, and then + terminates. This works only in test mode. This allows you + to embed tsshbatch in external shell scripts like this: + + for server in $(tsshbatch.py -i devserverlist -uatserverlist -W) + do + ssh $server + done + + Why? Because tsshbatch has lots of powerful ways to maintain + inventories of hosts and combine them through includes and + multiple command line arguments. The -W option makes it + convenient for external programs to make use of those inventory + features. + [CHANGES] -- The -H option can now appear on the command line multiple times - thereby creating an aggregate list of all hosts named therein. + - The -H option can now appear on the command line multiple times + thereby creating an aggregate list of all hosts named therein. -- Hostfiles must now be passed as an argument of -i. This was - done to provide a consistent way of passing multiple host - files on the commandline. + - Hostfiles must now be passed as an argument of -i. This was + done to provide a consistent way of passing multiple host + files on the commandline. [BUG FIXES] -- File transfers now properly honor the -s (silent output) flag. + - File transfers now properly honor the -s (silent output) flag. TODO ---- -- Options for searching all the command files and hostlistfiles + - Options for searching all the command files and hostlistfiles -- File Xfer: Allow from within cmd files. + - File Xfer: Allow from within cmd files. -- Show incremental output as program executes - -- Add ability to try keys first, and if that fails, use a password. - -- File Xfer: Renaming - -- File Xfer: Globing - what about dirs, do we recurse? - -- Interactive shell? + - Interactive shell? -sudoers Mode ------------- +Future +------ -- Capture bad password -- Capture failed command output -- Write the server noise, as it appears to stderr for debug purposes -- Note in docs: In this mode it will HANG waiting for interactive input. -- Note in docs: There is no separation between stdout and sterr in this mode + - Show incremental output as program executes + + - File Xfer: Renaming - Cmdfile? + + - File Xfer: Globing - what about dirs, do we recurse? - Cmdfile? + + - implement sudoers Mode: + + - Capture bad password + - Capture failed command output + - Write the server noise, as it appears to stderr for debug purposes + - Note in docs: In this mode it will HANG waiting for interactive input. + - Note in docs: There is no separation between stdout and sterr in this mode diff --git a/tsshbatch.py b/tsshbatch.py index 0133eb0..02ae6a3 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -14,7 +14,7 @@ # Version Information - Overwritten by makefile during release process ##### -GITID = '64f745e tundra Fri Sep 30 15:35:13 2016 -0500' +GITID = 'ba75286 tundra Fri Sep 30 15:59:00 2016 -0500' VERSION = '1.311' @@ -87,7 +87,7 @@ HOSTNOISE = '[%s]' HOSTLIST = 'Hosts' INDENTWIDTH = 8 -OPTIONSLIST = 'BC:EG:H:KLNP:ST:abef:hi:kl:n:p:qstvxy' +OPTIONSLIST = 'BC:EG:H:KLNP:ST:Wabef:hi:kl:n:p:qstvxy' PADWIDTH = 12 PATHDELIM = ':' PATHSEP = os.sep @@ -106,7 +106,7 @@ USAGE = \ PROGVER + "\n" +\ HOMEPAGE + "\n\n" +\ - "Usage: tsshbatch.py [-BEKLNSTaehkqstvy -C configfile -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' -i 'hostfile ...' [command arg ... ]\n" +\ + "Usage: tsshbatch.py [-BEKLNSTWaehkqstvy -C configfile -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' -i 'hostfile ...' [command arg ... ]\n" +\ " where,\n" +\ "\n" +\ " -B Print start and stop statistics (Off)\n" +\ @@ -120,6 +120,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 (15 sec)\n" +\ + " -W Write list of hosts to stdout and exit\n" +\ " -a Don't abort program after failed file transfers (Abort on failure)\n" +\ " -b Don't abort program after failed sudo command (Abort on failure)\n" +\ " -e Don't report remote host stderr output (Report host stderr) \n" +\ @@ -224,6 +225,7 @@ TESTMODE = True # Run program in test mode, don't actually execute commands TIMEOUT = 15 # Connection attempt timeout (sec) UNAME = "" # Login name +WRITEINVENTORY = False # Write list of selected hosts to stdout as a single line # Noise levels @@ -893,6 +895,9 @@ except: ErrorExit(eBADTIMEOUT) + if opt == "-W": + WRITEINVENTORY = True + if opt == "-a": ABORTONFXERROR = False @@ -911,7 +916,7 @@ if opt == "-i": for hostfile in val.split(): - Hosts += ReadFile(hostfile, os.getenv(HOSTINCL), Hosts) + Hosts = ReadFile(hostfile, os.getenv(HOSTINCL), Hosts) if opt == "-k": KEYEXCHANGE = True @@ -1111,16 +1116,23 @@ Hosts[index] = VarSub(Hosts[index]) index += 1 - for prompt, description, items in ((TESTRUN, " ".join(OPTIONS), ["\n"]), - (SYMTABLE, "", symtbl + ["\n"]), - (HOSTLIST, "", Hosts + ["\n"]), - (GETFILES, "", gets + ["\n"]), - (PUTFILES, "", puts + ["\n"]), - (COMMANDS, "", Commands + ["\n"]) - ): + # Write the inventory out if that's all that was asked for - PrintReport([prompt, description] + items) + if WRITEINVENTORY: + PrintStdout(" ".join(Hosts)) + # Otherwise, print the summary + + else: + for prompt, description, items in ((TESTRUN, " ".join(OPTIONS), ["\n"]), + (SYMTABLE, "", symtbl + ["\n"]), + (HOSTLIST, "", Hosts + ["\n"]), + (GETFILES, "", gets + ["\n"]), + (PUTFILES, "", puts + ["\n"]), + (COMMANDS, "", Commands + ["\n"]) + ): + + PrintReport([prompt, description] + items) # Otherwise, actually do the work by iterating over the list of hosts, # executing any file transfers and commands. Accomodate commenting @@ -1140,6 +1152,7 @@ protected.append(builtin) # Now iterate over requested hosts + hostnum = 0 for host in Hosts: diff --git a/tsshbatch.rst b/tsshbatch.rst index 9c50f6b..b0f3dd2 100644 --- a/tsshbatch.rst +++ b/tsshbatch.rst @@ -30,7 +30,7 @@ -------- :: - tsshbatch.py [-EKLNSTaehkqstvxy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' -i 'hostfile ...' [command arg ... ] + tsshbatch.py [-EKLNSTWaehkqstvxy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' -i 'hostfile ...' [command arg ... ] DESCRIPTION ----------- @@ -132,6 +132,25 @@ -T seconds Set timeout for ssh connection attempts. (Default: 15 seconds) + -W Print out a single line list of the inventory that would + be processed and exit. (Test mode only - Ignored in + execution mode.) + + This allows you to embed ``tsshbatch`` in external + shell scripts like this:: + + for server in $(tsshbatch.py -i devserverlist -uatserverlist -W) + do + ssh $server + done + + Why? Because tsshbatch has lots of powerful ways + to maintain inventories of hosts and combine them + through includes and multiple command line + arguments. The ``-W`` option makes it convenient for + external programs to make use of those inventory + features. + -a Don't abort program after failed file transfers. Continue to next transfer attempt. (Default: Abort) @@ -1243,7 +1262,7 @@ :: - $Id: '64f745e tundra Fri Sep 30 15:35:13 2016 -0500' + $Id: 'ba75286 tundra Fri Sep 30 15:59:00 2016 -0500' This document was produced with ``emacs``, ``RestructuredText``, and ``TeX Live``.