diff --git a/tsshbatch.py b/tsshbatch.py index fbeb278..a3b21c4 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.174 2014/03/27 21:26:30 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.175 2014/03/27 22:04:09 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" DATE = "2011-2013" @@ -117,7 +117,16 @@ DEFINE = '.define' INCLUDE = '.include' + +##### +# Hostname substitution support +##### + + HOSTNAME = '' +HOSTSHORT = '' +HostName = "" +HostShort = "" SymbolTable = {} @@ -248,12 +257,16 @@ for src in filelist: # Resolve references to hostname in source file specification - srcfile = src.replace(HOSTNAME, host) + + srcfile = src.replace(HOSTNAME, HostName) + srcfile = src.replace(HOSTSHORT, HostShort) for destdir in filelist[src]: # Resolve references to hostname in destination directory specification - destdir = destdir.replace(HOSTNAME, host) + + destdir = destdir.replace(HOSTNAME, HostName) + destdir = destdir.replace(HOSTSHORT, HostShort) # Make sure we have a trailing path separator destination = destdir @@ -304,7 +317,9 @@ for command in commands: # Resolve references to hostname within the command string - command = command.replace(HOSTNAME, host) + + command = command.replace(HOSTNAME, HostName) + command = command.replace(HOSTSHORT, HostShort) # It's possible to get blank lines from stdin. # Ignore them. @@ -775,6 +790,9 @@ for host in Hosts: + HostName = host + HostShort = host.split('.')[0] + if Get_Transfer_List: HostFileTransfer(host, UNAME, PWORD, Get_Transfer_List, GET=True)