diff --git a/tsshbatch.py b/tsshbatch.py index d4f4182..11c3d1d 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.188 2014/11/25 23:14:48 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.189 2014/11/25 23:51:40 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" DATE = "2011-2014" @@ -69,7 +69,7 @@ HOSTNOISE = '[%s]' HOSTLIST = 'Hosts' INDENTWIDTH = 8 -OPTIONSLIST = 'EKG:H:NP:ST:aef:hkn:p:tvxy' +OPTIONSLIST = 'EKG:H:NP:ST:aef:hkl:n:p:tvxy' PADWIDTH = 12 PATHDELIM = ':' PATHSEP = os.sep @@ -86,29 +86,30 @@ USERVAR = 'USER' USAGE = \ - PROGVER + "\n" +\ - HOMEPAGE + "\n\n" +\ - "Usage: tsshbatch.py [-EKNSTaehkvxy -G 'file dest' -P 'file dest' -f cmdfile -n name -p pw ] -H 'host ..' | hostlistfile [command arg ... ]\n" +\ - " where,\n" +\ - "\n" +\ - " -E Write error output to stdout instead of stderr\n" +\ - " -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" +\ - " -N Force prompting for username\n" +\ - " -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\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" +\ - " -k Use key exchange-based authentication\n" +\ - " -n name Specify login name\n" +\ - " -p pw Specify login password\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" +\ + 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" +\ + " where,\n" +\ + "\n" +\ + " -E Write error output to stdout instead of stderr\n" +\ + " -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" +\ + " -N Force prompting for username\n" +\ + " -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" +\ + " -e Don't report remote host stderr output\n" +\ + " -f cmdfile Read commands from file\n" +\ + " -h Display help\n" +\ + " -k Use key exchange-based authentication\n" +\ + " -l logfile Log errors to logfile (Default: /dev/null)\n" +\ + " -n name Specify login name\n" +\ + " -p pw Specify login password\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" +\ " -y Turn on 'noisy' reporting for additional detail\n" @@ -172,18 +173,19 @@ # Options That Can Be Overriden By User #### -ABORTONFXERROR = True # Abort after a file transfer error -GETSUDOPW = False # Prompt for sudo password -Hosts = [] # List of hosts to target -KEYEXCHANGE = False # Do key exchange-based auth? -NOISY = False # Print output with extra detail -PROMPTUSERNAME = False # Don't use $USER, prompt for username -PWORD = "" # Password -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 -TIMEOUT = 15 # Connection attempt timeout (sec) -UNAME = "" # Login name +ABORTONFXERROR = True # Abort after a file transfer error +GETSUDOPW = False # Prompt for sudo password +Hosts = [] # List of hosts to target +KEYEXCHANGE = False # Do key exchange-based auth? +LOGFILE = "/dev/null" # Where paramiko logging output goes +NOISY = False # Print output with extra detail +PROMPTUSERNAME = False # Don't use $USER, prompt for username +PWORD = "" # Password +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 +TIMEOUT = 15 # Connection attempt timeout (sec) +UNAME = "" # Login name ##### @@ -642,6 +644,9 @@ if opt == "-k": KEYEXCHANGE = True + if opt == "-l": + LOGFILE = val + if opt == "-n": UNAME = val @@ -663,6 +668,13 @@ ##### +# Intitialize paramiko Logging +##### + +paramiko.util.log_to_file(LOGFILE) + + +##### # Host & Command Line Command Definition Processing #####