diff --git a/tsshbatch.py b/tsshbatch.py index 6dec9b8..50355b1 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -17,7 +17,7 @@ PROGNAME = "tsshbatch.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -CVSID = "$Id: tsshbatch.py,v 1.152 2013/10/23 16:20:29 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.153 2013/10/23 18:05:04 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" @@ -217,6 +217,7 @@ if KEYEXCHANGE: ssh.connect(host) + else: ssh.connect(host, username=user, password=pw) @@ -401,7 +402,6 @@ PrintStdout(CVSID) sys.exit() - ##### # Go Do The Requested Work ##### @@ -409,28 +409,25 @@ # Precedence of authentication credential sources: # # 1) Key exchange -# 2) Command Line/$TSSHBATCH env variable sets name and/or password -# 3) Forced prompting for name via -N +# 2) Forced prompting for name via -N +# 2) Command Line/$TSSHBATCH env variable sets name # 4) Name picked up from $USER (Default behavior) if not KEYEXCHANGE: # Preset commandline and/or program option variable username takes precedence + if not UNAME: - - current_user = os.getenv("USER") + UNAME = os.getenv("USER") - # By default, use $USER as the login name and don't prompt for it - if not PROMPTUSERNAME: + # By default, use the above as the login name and don't prompt for it + # unless overriden on the command line with -N + if PROMPTUSERNAME: + current_user = UNAME + UNAME = raw_input(pUSER %current_user) + if not UNAME: # User just hit return - wants default UNAME = current_user - # Interactive prompting using $USER as default - else: - - UNAME = raw_input(pUSER % current_user) - if not UNAME: # User just hit return - wants default - UNAME = current_user - # Preset commandline and/or program option variable password takes precedence if not PWORD: PWORD = getpass.getpass(pPASS) @@ -484,6 +481,7 @@ elif command: Commands = [command,] + # The need to prompt for a sudo password depends on a number of # conditions: #