Version |
Releasedate |
Description
|
v0.0.1 |
28.02.2008 | initial release |
v0.0.2 |
29.02.2008 |
## 28.02.2008
v0.0.2 /bs ## added parameter hostlist, scriptfile, outputfile, and user ## added the parameter -U ## the script now supports multiple hostlists ## |
v0.0.3 |
03.03.2008 |
## 03.03.2008
v0.0.3 /bs ## added additional workarounds for CYGWIN ## added the parameter -I ## added a Summary about failed hosts ## changed __ONLY_ONCE to ${__FALSE} ## added code to print a warning if ssh-agent is not running ## |
v0.0.4 |
04.03.2008 |
## 04.03.2008
v0.0.4 /bs ## changed the default output filename to "/var/tmp/${__SCRIPTNAME##*/}.$$.log" ## added code to call dos2unix for the script file if running in CYGWIN ## |
v0.0.5 |
01.08.2008 |
## 01.08.2008
v0.0.5 /bs ## corrected a syntax error in the routine to print the short usage ## set read permissions for the script before executing scp if necessary ## added the parameter -p scpoptions and -P sshoptions ## added code to sort the list of hosts and remove duplicate entries ## |
v0.0.6 |
07.08.2008 |
## 07.08.2008
v0.0.6 /bs ## corrected a syntax error ## |
v0.0.7 |
20.09.2008 |
## 20.09.2008
v0.0.7 /bs ## added the option -K / --nostrictkeys |
v0.0.10 |
30.03.2011 | ## 30.03.2011
v0.0.10 /bs ## added the parameter -b / --ssh_keyfile ## added the parameter -B / --do_not_copy ## |
v1.0.0 |
31.05.2013 |
## 31.05.2013
v1.1.0 /bs ## executeCommandAndLog rewritten using coprocesses (see also credits) ## Info update: executeCommandAndLog does now return the RC of the executed ## command even if a logfile is defined ## replaced the runtime system with scriptt.sh v2.0.0 ## the commands can now run in parallel in the background ## (parameter -d, -w, and -W) ## |
v1.1.0 |
06.06.2013 |
## 06.06.2013
v1.1.0 /bs ## the parameter -W and now supports a syntax like -W /5 and the ## "/" can be replaced by "," ## the parameter -w and now supports a syntax like -w /5, -w /5/20, ## or -w //10. "/ "can be replaced by "," ## You can now use seconds, minutes, or hours for the time values ## of the parameter -w and -W can now ## |
v1.2.0 |
28.05.2014 |
## 28.05.2014
v1.2.0 /bs ## use scriptt.sh v2.0.0.6 ## added the parameter -x (--excludehost) ## added the parameter -A (--includehost) ## enhanced support for binaries ## reworked the usage help ## replaced "which" whith "whence" ## |
v1.3.0 |
19.09.2014 |
## 19.09.2014
v1.3.0 /bs ## the script now supports the format user@host ## |
v1.3.1 |
27.04.2014 |
## 27.09.2014
v1.3.1 /bs ## added the keyword ignore_user_in_file for the parameter -D ## added the keyword do_not_sort_hostlist for the parameter -D ## added the keyword ssh_binary for the parameter -D ## added the keyword scp_binary for the parameter -D ## added the keyword dos2unix_binary for the parameter -D ## |
v2.0.0 |
24.07.0215 |
## 24.07.2015
v2.0.0 /bs ## added support for different user for ssh and scp (parameter -u) ## added support for different ssh key files for the ssh and scp user ## added an option to list all hosts to the question to start the script ## added parameter to enable the forward agent for scp (parameter -D enable_ForwardAgent_for_scp) ## added support for templates for the scp usage (parameter -t scp:scp_template) ## added support for templates for the ssh usage (parameter -t ssh:ssh_template) ## The scp/ssh templates are useful if a golden host is used to access the machines ## added t{SED_SEP}he debug options (parameter -D) from scriptt.sh version 2.1.0.7 21.07.2015 ## added single step mode for sequential usage (parameter -D singlestep) ## added dry run mode (parameter -D dryrun) ## added a parameter to cleanup the known_hosts (parameter -D clean_known_hosts) ## added an example for golden host usage (parameter -D sls_db) ## added the parameter "-D if=xx" ## the parameter -K now also adds the options "-o NumberOfPasswordPrompts=0 -o ConnectTimeout=10" ## to scp and ssh if running in parallel mode ## |
v2.0.1 |
009.10.2015 |
## 09.10.2015
v2.0.1 /bs ## added support for scp via sls; the sls parameter are now: ## -D sls_scp_db sls for scp for DB ## -D sls_ssh_db sls for ssh for DB ## -D sls_ssh_fms sls for ssh for FMS ## ## -D sls_fms sls for scp and ssh for FMS ## -D sls_db sls for scp and ssh for DB ## |
v2.1.0 |
24.10.2015 |
## 24.10.2015
v2.1.0 /bs ## added support for field separators in the hostlist files (filename[:separator]) ## added the keyword fieldsep=x to the parameter -D to change the default field separator ## added the keyword printargs to the parameter -D ## now the parameter -i hostlist is optional if -A hostname is used ## now the parameter -x hostexcludelist supports a leading "?" for ## optional hostexcludelist files ## reworked the messages written by the script (in normal mode and ## in verbose mode) ## the parameter "-x none" did not work --fixed ## the usage with "hostfile scriptfile .." did not work --fixed ## the script now reset the current terminal using "stty sane" at ## script end ## the parameter -K now also adds the options "-o BatchMode=yes -o PasswordAuthentication=no" ## to scp and ssh if running in parallel mode ## |
v2.2.0 |
27.10.2015 |
## 27.10.2015
v2.2.0 /bs ## execute_on_all_hosts.sh now creates up to 10 backups of the logfile ## and rewrites the logfile every time. ## To overwrite the number of backups use the following syntax for ## the parameter -l: ## ## -l logfile,[no_of_backups_of_the_logfile] ## ## The default number of backups for the log file is configured in the variable ## MAX_NO_OF_LOGFILES ## |
v2.2.1 |
25.11.2015 |
## 25.11.2015
v2.2.1 /bs ## the internal sed field separator is now "CTRL-X" so the pipe character ## "|" can be used in commands to execute again (see the variable SED_SEP) |
v2.2.2 |
25.08.2017 |
## 25.08.2017 v2.2.2 /bs ## the parameter -t did not support templates with colon ":" - fixed ## the script printed in some circumstances the wrong number of hosts to process in the summary (There are 2 hosts to process) - fixed ## |
v2.2.3 |
26.08.2017 |
## 26.08.2017 v2.2.3 /bs ## New macros for the parameter -D: ## ## -D sls_scp_db_unxxx4 sls for scp for DB as user unxxx4 ## -D sls_ssh_db_unxxx4 sls for ssh for DB as user unxxx4 ## -D sls_db_unxxx4 sls for scp and ssh for DB as user unxxx4 ## -D ticket_id=x define ticket id for DB access ## -D use_ssh_wrapper use my ssh and scp wrapper script for SLS ## -D no_use_ssh_wrapper do not use my ssh and scp wrapper script for SLS ## ## the ticket string set with the parameter "-D ticket_id=x" is now part of the ## default ssh and scp template (in the default the ticket string is empty) ## ## improved some error messages to be more clear ## in the code to enable the forward agent for scp (ENABLE_FORWARD_AGENT_FOR_SCP_CODE) ## was a "=" missing so that it did not work -- fixed ## |
v2.3.0 |
21.07.2021 |
## 21.07.2021 v2.3.0 /bs ## the parameter "-W timeout/intervall" now defines the timeout for the scp and ssh commands and the intervall ## between the ssh/scp commands for the machines if running in sequential mode ## (note: a timeout value will only work if the executable "timeout" is available via the PATH; see the source code for ## a timeout implementation in a ksh script) ## the script now prints a summary at script end like this : ## (the 2nd line is only shown in sequential mode): ## ## [16.07.2021 08:52:23] The script runtime is (day:hour:minute:seconds) 0:00:04:33 (= 273 seconds) for 84 hosts ## [16.07.2021 08:52:23] ( -> about 4 second(s) her host) ## ## added the template sls_db_unxxx4_w_timeout (-D sls_db_unxxx4_w_timeout) : ## Use sls as user unxxx4 to connect with a timeout of 15 seconds for each ssh/scp command ## Set the variable SSH_SCP_CMD_TIMEOUT before starting the script change the timeout value ## (note: The template will only work if the executable "timeout" is available via the PATH; see the source code for ## a timeout implementation in a ksh script) ## added the alias "sls" for sls_db_unxxx4_w_timeout ## the macrco sls_db_unxxx4 (and also sls_db_unxxx4_w_timeout) now uses the scp and ssh binaries defined ## with the parameter "-D ssh_binary=x" or "-D scp_binary=x" if defined (def. values are /usr/bin/ssh and /usr/bin/scp) ## the function die will now call the al<<ias __unsettraps if the script is running in Solaris ## LogRuntimeInfo rewritten -- the old syntax did not work in the ksh from Solaris 11 ## added the keyword log_ssh_cmds for the parameter -D ## added the keyword do_not_log_ssh_cmds for the parameter -D ## the value for the setting "-o ConnectTimeout" used if the parameter "-K" is used in parallel mode can be defined using the ## environment variable SSH_SCP_CMD_TIMEOUT or the parameter -W ## the script now prints the list of hosts on which the executed command ended with a non-zero return code ## at script end if running in sequential mode ## disabled a wrong error message regarding restoring the known_hosts file ## the script ignored the return code of the scp command in sequential mode -- fixed ## the output of the ssh and scp commands in sequential mode was not written to the logfile -- fixed ## (use the parameter "-D do_not_log_ssh_cmds" to disable the logging of the ssh command output to the logfile) ## fixed some typos ## fixed some minor errors ## ${__FUNCTION_EXIT} was executed twice in the function isNumber -- fixed ## the initial runtime code was missing in the functions LogHeader, rand, PrintLockFileErrorMsg, and USER_SIGNAL_HANDLER -- fixed ## the script did not print the list of failed hosts at script end in sequential mode -- fixed ## |
v2.3.1 |
08.09.2022 |
## 08.09.2022 v2.3.1 /bs ## the script now also removes the entries for the IP addresses from the known_hosts file if the parameter "-D clean_known_hosts" is used ## the script now also uses ssh-keygen to remove entries from the known_hosts file if the parameter "-D clean_known_hosts" is used ## (-> hashed entries in the file will also be removed) ## added the keyword ssh-keygen_binary for the parameter -D ## added the keyword nameserver for the parameter -D ## added the keyword delete_known_hosts for the parameter -D ## added the keyword clean_and_restore_known_hosts for the parameter -D ## added the keyword delete_and_restore_known_hosts for the parameter -D ## added the keyword ignore_known_hosts for the parameter -D ## added the keyword SLS_db_unxxx4 for the parameter -D ## added the keyword SLS_db_unxxx4_sudo for the parameter -D ## added the keyword sls_db_unxxx4_sudo for the parameter -D ## added the variable TRACE_MAIN (-> trace the main function if the variable TRACE_MAIN is set to 0 before starting the script) ## added the variable TRACE_PROMPT (-> PS4 prompt used for tracing the main function; set this variable before starting the script) ## |
v2.3.2 | 09.12.2022 | ## 09.12.2022 v2.3.2 /bs ## the macro sls_ssh_db_unxxx4 was not working -- fixed ## |
v2.3.3 | 05.02.2023 | ## 05.02.2023 v2.3.3 /bs ## the function CalculateSeconds did not handle values ending with a "h" correct -- fixed ## |
v2.3.4 | 20.02.2023 | ## 20.02.2023 v2.3.4 /bs ## the script did not like leading white spaces in the files with the host lists -- fixed ## |
v2.3.5 | 12.01.2024 | ## 12.01.2024 v2.3.5 /bs ## replaced "egrep" with "grep -E" (see variable EGREP) ## corrected some minor bugs in the commands to print messages ## |
# the file with the list of
hosts: # xtrnaw7@t30:/data/develop/scripts$ cat hosts # machines in my testenvironment sol9 pb001 ferrari sol8 sol2 sol3 ultra30 # The file with the commands to execute on each host: # xtrnaw7@t30:/data/develop/scripts$ cat testscript0 uname -a # run the script (using the user root on the target hosts): # xtrnaw7@t30:/data/develop/scripts$ ./execute_on_all_hosts.sh -i hosts -s testscript0 -u root [28.02.2008 21:01:03] execute_on_all_hosts.sh started on Thu Feb 28 21:01:03 CET 2008 [28.02.2008 21:01:03] Reading the config file "./execute_on_all_hosts.conf" ... [28.02.2008 21:01:03] Using the log file "/var/tmp/execute_on_all_hosts.LOG" [28.02.2008 21:01:03] [28.02.2008 21:01:03] Executing the script [28.02.2008 21:01:03] testscript0 [28.02.2008 21:01:03] as ssh user [28.02.2008 21:01:03] root [28.02.2008 21:01:03] on every host listed in the file [28.02.2008 21:01:03] hosts [28.02.2008 21:01:03] [28.02.2008 21:01:03] The shell to execute the script is [28.02.2008 21:01:03] /usr/bin/ksh [28.02.2008 21:01:03] The output of the commands will be logged in the file [28.02.2008 21:01:03] /var/tmp/execute_on_all_hosts.sh.19003.log [28.02.2008 21:01:03] Okay (y/N)? y [28.02.2008 21:01:06] Starting processing ... [28.02.2008 21:01:06] ---- Processing "sol9" ... testscript0 100% 9 0.0KB/s 00:00 SunOS sol9 5.11 snv_78 sun4u sparc sun4u [28.02.2008 21:01:09] ---- Processing "pb001" ... testscript0 100% 9 0.0KB/s 00:00 SunOS pb001 5.11 snv_78 i86pc i386 i86pc [28.02.2008 21:01:10] ---- Processing "ferrari" ... ssh: connect to host ferrari port 22: No route to host lost connection [28.02.2008 21:01:13] ERROR: Error copying the script to the host "ferrari" - could not execute the script on that host [28.02.2008 21:01:13] ---- Processing "sol8" ... ssh: connect to host sol8 port 22: Connection refused lost connection [28.02.2008 21:01:13] ERROR: Error copying the script to the host "sol8" - could not execute the script on that host [28.02.2008 21:01:13] ---- Processing "sol2" ... testscript0 100% 9 0.0KB/s 00:00 SunOS sol2 5.10 Generic_127111-03 sun4u sparc SUNW,Ultra-5_10 [28.02.2008 21:01:16] ---- Processing "sol3" ... ssh: connect to host sol3 port 22: No route to host lost connection [28.02.2008 21:01:19] ERROR: Error copying the script to the host "sol3" - could not execute the script on that host [28.02.2008 21:01:19] ---- Processing "ultra30" ... Warning: the RSA host key for 'ultra30' differs from the key for the IP address '192.168.1.20' Offending key for IP in /home/xtrnaw7/.ssh/known_hosts:13 Matching host key in /home/xtrnaw7/.ssh/known_hosts:40 testscript0 100% 9 0.0KB/s 00:00 Warning: the RSA host key for 'ultra30' differs from the key for the IP address '192.168.1.20' Offending key for IP in /home/xtrnaw7/.ssh/known_hosts:13 Matching host key in /home/xtrnaw7/.ssh/known_hosts:40 SunOS ultra30 5.10 Generic_120011-14 sun4u sparc SUNW,Ultra-30 [28.02.2008 21:01:21] [28.02.2008 21:01:21] All done [28.02.2008 21:01:21] [28.02.2008 21:01:21] The output of the commands is logged in the file [28.02.2008 21:01:21] /var/tmp/execute_on_all_hosts.sh.19003.log [28.02.2008 21:01:21] [28.02.2008 21:01:21] The log file used was "/var/tmp/execute_on_all_hosts.LOG" [28.02.2008 21:01:21] execute_on_all_hosts.sh ended on Thu Feb 28 21:01:21 CET 2008. [28.02.2008 21:01:21] The RC is 0. # The output of the commands is written to the logfile: xtrnaw7@t30:/data/develop/scripts$ cat /var/tmp/execute_on_all_hosts.sh.19003.log # ### ---- Log of the script executed on host "sol9" --- start --- SunOS sol9 5.11 snv_78 sun4u sparc sun4u # ### ---- Log of the script executed on host "sol9" --- end --- # ### ---- Log of the script executed on host "pb001" --- start --- SunOS pb001 5.11 snv_78 i86pc i386 i86pc # ### ---- Log of the script executed on host "pb001" --- end --- # ### ---- Log of the script executed on host "sol2" --- start --- SunOS sol2 5.10 Generic_127111-03 sun4u sparc SUNW,Ultra-5_10 # ### ---- Log of the script executed on host "sol2" --- end --- # ### ---- Log of the script executed on host "ultra30" --- start --- Warning: the RSA host key for 'ultra30' differs from the key for the IP address '192.168.1.20' Offending key for IP in /home/xtrnaw7/.ssh/known_hosts:13 Matching host key in /home/xtrnaw7/.ssh/known_hosts:40 SunOS ultra30 5.10 Generic_120011-14 sun4u sparc SUNW,Ultra-30 # ### ---- Log of the script executed on host "ultra30" --- end --- |
This section contains some hints and tips using the script.