diff --git a/TODO b/TODO index b2391ee..d3d0f90 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,9 @@ 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. + [CHANGES] - The -H option can now appear on the command line multiple times @@ -24,8 +27,6 @@ - Make file xfer noise go away with -s -- Add feature to display names of all possible hostfiles/cmdfiles - - Add lshost feature - File Xfer: Allow from within cmd files. diff --git a/tsshbatch.py b/tsshbatch.py index 68487d3..bc64623 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -87,7 +87,7 @@ HOSTNOISE = '[%s]' HOSTLIST = 'Hosts' INDENTWIDTH = 8 -OPTIONSLIST = 'BC:EKG:H:NP:ST:abef:hi:kl:n:p:qstvxy' +OPTIONSLIST = 'BC:EG:H:KLNP:ST:abef:hi:kl:n:p:qstvxy' PADWIDTH = 12 PATHDELIM = ':' PATHSEP = os.sep @@ -106,7 +106,7 @@ USAGE = \ PROGVER + "\n" +\ HOMEPAGE + "\n\n" +\ - "Usage: tsshbatch.py [-BEKNSTaehkqstvy -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 [-BEKLNSTaehkqstvy -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" +\ @@ -115,6 +115,7 @@ " -K Force password prompting - Overrides previous -k\n" +\ " -G 'file dest' GET file on host and write local dest directory\n" +\ " -H '...' List of targeted hosts passed as a single argument\n" +\ + " -L List all known hostfiles and cmdfiles, and exit\n" +\ " -N Force prompting for username\n" +\ " -P 'file dest' PUT local file to host dest directory\n" +\ " -S Force prompting for sudo password\n" +\ @@ -189,6 +190,8 @@ # Informational Messages ##### +iCMDFILES = "Command Files:\n==============\n" +iHOSTFILES = "Host Files:\n===========\n" iNOCFGFILE = "Warning: Cannot Open Configuration File '%s'! Continuing Anyway ..." iTXFILE = "Writing %s To %s ..." @@ -850,6 +853,28 @@ if opt == "-H": Hosts += val.split() + if opt == "-L": + + h = os.getenv(HOSTINCL) or '' + c = os.getenv(CMDINCL) or '' + for hdr, slist in [[iHOSTFILES, h.split(PATHDELIM)], + [iCMDFILES, c.split(PATHDELIM)]]: + + found = [] + if slist: + + for p in slist: + if p: + lsdir = os.listdir(p) + if not p.endswith(PATHSEP): + p += PATHSEP + found += [ p+x for x in lsdir] + + PrintStdout(hdr) + PrintStdout("\n".join(found), EOL="\n\n") + + sys.exit() + if opt == "-N": PROMPTUSERNAME = True KEYEXCHANGE = False diff --git a/tsshbatch.rst b/tsshbatch.rst index 6604d8a..60efc58 100644 --- a/tsshbatch.rst +++ b/tsshbatch.rst @@ -30,7 +30,7 @@ -------- :: - tsshbatch.py [-EKNSTaehkqstvxy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' -i 'hostfile ...' [command arg ... ] + tsshbatch.py [-EKLNSTaehkqstvxy -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ..' -i 'hostfile ...' [command arg ... ] DESCRIPTION ----------- @@ -110,6 +110,10 @@ times. The hosts will be processed in the order in which they appeared on the command line. + -L List names of all (if any) host- and command files + found on their respective search paths. These are + listed in the order they are found on those paths. + -N Force interactive username dialog. This cancels any previous request for key exchange authentication.