Jean-Francois Pieronne - 4 years ago 2016-11-30 17:51:03
jf.pieronne@laposte.net
OpenVMS update
1 file changed with 46 insertions and 13 deletions:
↑ Collapse Diff ↑
...
 
@@ -15,7 +15,7 @@
15 15
 
#####
16 16
 

	
17 17
 
GITID      = '345a9ed tundra Sat Oct 15 16:12:01 2016 -0500'
18
 
VERSION    = '1.317'
18
 
VERSION    = '1.317-vms'
19 19
 

	
20 20
 

	
21 21
 
#####
...
 
@@ -89,7 +89,8 @@ HOSTLIST     = 'Hosts'
89 89
 
INDENTWIDTH  = 8
90 90
 
NOMATCH      = "No string matches!"
91 91
 
NOTIFICATION = 'NOTIFICATION'
92
 
OPTIONSLIST  = 'BC:EF:G:H:KLNP:ST:V:Wabef:hi:kl:n:p:qrstvxy'
92
 
OPENVMSMODE  = False
93
 
OPTIONSLIST  = 'BC:EF:G:H:KLNOP:ST:V:Wabcef:hi:kl:n:p:qrstvxy'
93 94
 
PADWIDTH     = 12
94 95
 
PATHDELIM    = ':'
95 96
 
PATHSEP      = os.sep
...
 
@@ -108,7 +109,7 @@ USERVAR      = 'USER'
108 109
 
USAGE        = \
109 110
 
    PROGVER  + "\n"                                                                                     +\
110 111
 
    HOMEPAGE + "\n"                                                                                     +\
111
 
    "Usage:  tsshbatch.py [-BEF:KLNSTVWaehkqrstvy -C configfile -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ...' -i 'hostfile ...' [command arg ... ]\n" +\
112
 
    "Usage:  tsshbatch.py [-BEF:KLNOSTVWacehkqrstvy -C configfile -G 'file dest' -P 'file dest' -f cmdfile -l logfile -n name -p pw ] -H 'host ...' -i 'hostfile ...' [command arg ... ]\n" +\
112 113
 
    "          where,\n"                                                                                +\
113 114
 
    "\n"                                                                                                +\
114 115
 
    "            -B                  Print start and stop statistics (Off)\n"                               +\
...
 
@@ -127,6 +128,7 @@ USAGE        = \
127 128
 
    "            -W                  Write list of hosts to stdout and exit\n"                              +\
128 129
 
    "            -a                  Don't abort program after failed file transfers (Abort on failure)\n"  +\
129 130
 
    "            -b                  Don't abort program after failed sudo command (Abort on failure)\n"    +\
131
 
    "            -c                  In OpenVMS mode, continue on command error\n"                          +\
130 132
 
    "            -e                  Don't report remote host stderr output (Report host stderr) \n"        +\
131 133
 
    "            -f cmdfile          Read commands from file\n"                                             +\
132 134
 
    "            -h                  Display help\n"                                                        +\
...
 
@@ -135,6 +137,7 @@ USAGE        = \
135 137
 
    "            -l logfile          Log errors to logfile (/dev/null)\n"                                   +\
136 138
 
    "            -n name             Specify login name\n"                                                  +\
137 139
 
    "            -p pw               Specify login password\n"                                              +\
140
 
    "            -O                  OpenVMS mode\n"		                                            +\
138 141
 
    "            -q                  Quiet mode - produce less 'noisy' output\n"                            +\
139 142
 
    "            -r                  Suppress reporting of start/stop statistics\n"                         +\
140 143
 
    "            -s                  Silence all program noise - only return command output\n"              +\
...
 
@@ -153,6 +156,8 @@ DEFINE      = '.define'
153 156
 
INCLUDE     = '.include'
154 157
 
LOCAL       = '.local'
155 158
 
NOTIFY      = '.notify'
159
 
ERRCONT     = '.continue'
160
 
ERRNOCONT   = '.nocontinue'
156 161
 

	
157 162
 

	
158 163
 
#####
...
 
@@ -218,6 +223,7 @@ pUSER = "Username (%s): "
218 223
 
# Options That Can Be Overriden By User
219 224
 
####
220 225
 

	
226
 
ABORTBADEXEC   = True           # OpenVMS mode, abort after a command error
221 227
 
ABORTBADSUDO   = True            # Abort after a sudo promotion error
222 228
 
ABORTONFXERROR = True            # Abort after a file transfer error
223 229
 
BANNERSON      = False           # Print start/stop banner info
...
 
@@ -515,6 +521,7 @@ def HostCommands(host, user, pw, sudopw,
515 521
 

	
516 522
 
        for command in commands:
517 523
 

	
524
 
            abortbadexec =  ABORTBADEXEC
518 525
 
            # Dereference variables
519 526
 

	
520 527
 
            command = VarSub(command)
...
 
@@ -532,17 +539,28 @@ def HostCommands(host, user, pw, sudopw,
532 539
 
                    PrintStdout("%s> %s\n" % (NOTIFICATION, " ".join(command.split(NOTIFY)).strip()))
533 540
 
                continue
534 541
 

	
535
 
            # If this is a sudo run, force password to be read
536
 
            # from stdin thereby avoiding fiddling around with ptys.
537
 

	
538
 
            if KeyInString(SUDO + " ", command):
539
 
                command = command.replace(SUDO, "%s %s" % (SUDO, SUDOARGS), 1)
542
 
            if OPENVMSMODE:
543
 
                if command.startswith(ERRCONT):
544
 
                    command = command[len(ERRCONT):]
545
 
                    abortbadexec =  False
546
 
                elif command.startswith(ERRNOCONT):
547
 
                    command = command[len(ERRNOCONT):]
548
 
                    abortbadexec =  True
549
 
                if abortbadexec:
550
 
                    cmd = 'pipe ' + command + ' ; write sys$output $status'
551
 
                else:
552
 
                    cmd = command
553
 
            else:
554
 
                # If this is a sudo run, force password to be read
555
 
                # from stdin thereby avoiding fiddling around with ptys.
556
 
                if KeyInString(SUDO + " ", command):
557
 
                    command = command.replace(SUDO, "%s %s" % (SUDO, SUDOARGS), 1)
558
 
                cmd = command
540 559
 

	
541
 
            stdin, stdout, stderr = ssh.exec_command(command)
560
 
            stdin, stdout, stderr = ssh.exec_command(cmd)
542 561
 

	
543
 
            # If doing a sudo command, send the password
544
 

	
545
 
            if KeyInString(SUDO + " ", command):
562
 
            if not OPENVMSMODE and  KeyInString(SUDO + " ", command):
563
 
                # If doing a sudo command, send the password
546 564
 
                stdin.write("%s\n" % sudopw)
547 565
 
                stdin.flush()
548 566
 

	
...
 
@@ -571,11 +589,20 @@ def HostCommands(host, user, pw, sudopw,
571 589
 
            if NOISELEVEL == QUIET:
572 590
 
                cmdreport = ""
573 591
 

	
574
 
            PrintReport([host + " (stdout)" + cmdreport, "\n"] + stdout.readlines() + ["\n"], FORMAT=Format)
592
 
            lines = stdout.readlines()
593
 
            if OPENVMSMODE and abortbadexec:
594
 
                retstat = lines[-2].strip()[1:]
595
 
                retstat = int('0' + retstat, 16)
596
 
                lines = lines[:-2]
597
 

	
598
 
            PrintReport([host + " (stdout)" + cmdreport, "\n"] + lines + ["\n"], FORMAT=Format)
575 599
 

	
576 600
 
            if REPORTERR:
577 601
 
                PrintReport([host + " (stderr)" + cmdreport, "\n"] + stderr.readlines() + ["\n"], HANDLER=PrintStderr, FORMAT=Format)
578 602
 

	
603
 
            if OPENVMSMODE and abortbadexec and (retstat & 1) == 0:
604
 
               raise SystemExit
605
 

	
579 606
 
    # Handle aborts
580 607
 

	
581 608
 
    except SystemExit:
...
 
@@ -990,6 +1017,9 @@ for opt, val in opts:
990 1017
 
        PROMPTUSERNAME = True
991 1018
 
        KEYEXCHANGE = False
992 1019
 

	
1020
 
    if opt == "-O":
1021
 
        OPENVMSMODE = True 
1022
 

	
993 1023
 
    if opt == "-P":
994 1024
 
        ProcessTXRQ(val, Put_Transfer_List)
995 1025
 

	
...
 
@@ -1011,6 +1041,9 @@ for opt, val in opts:
1011 1041
 
    if opt == "-b":
1012 1042
 
        ABORTBADSUDO = False
1013 1043
 

	
1044
 
    if opt == "-c":
1045
 
        ABORTBADEXEC = False
1046
 

	
1014 1047
 
    if opt == "-e":
1015 1048
 
        REPORTERR = False
1016 1049
 

	
0 comments (0 inline, 0 general)