diff --git a/tsshbatch.py b/tsshbatch.py index be1a60a..fbeb278 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.173 2014/01/20 17:32:42 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.174 2014/03/27 21:26:30 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" DATE = "2011-2013" @@ -117,6 +117,8 @@ DEFINE = '.define' INCLUDE = '.include' +HOSTNAME = '' + SymbolTable = {} @@ -232,7 +234,7 @@ try: ssh = paramiko.SSHClient() - # Connect and run the command, reporting results as we go + # Connect and run the command, reporting results as we go ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) @@ -243,8 +245,15 @@ sftp = ssh.open_sftp() - for srcfile in filelist: - for destdir in filelist[srcfile]: + for src in filelist: + + # Resolve references to hostname in source file specification + srcfile = src.replace(HOSTNAME, host) + + for destdir in filelist[src]: + + # Resolve references to hostname in destination directory specification + destdir = destdir.replace(HOSTNAME, host) # Make sure we have a trailing path separator destination = destdir @@ -294,6 +303,9 @@ for command in commands: + # Resolve references to hostname within the command string + command = command.replace(HOSTNAME, host) + # It's possible to get blank lines from stdin. # Ignore them.