Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
linux_wiki:command_many_systems_part2_send_cmd [2016/12/09 16:53] billdozor [Main Script File] |
linux_wiki:command_many_systems_part2_send_cmd [2016/12/09 16:54] billdozor [Worker Script File] |
||
---|---|---|---|
Line 491: | Line 491: | ||
# Name: worker_send-cmd.sh | # Name: worker_send-cmd.sh | ||
# Description: | # Description: | ||
- | # Last Updated: 2016-11-25 | + | # Last Updated: 2016-12-09 |
- | # Recent Changes:-File rename | + | # Recent Changes:-Added return code to output; newline after output; |
- | ############################################################## | + | # color to return code output |
+ | # -Moved ' | ||
+ | ###################### | ||
if [[ -z ${1} ]]; then | if [[ -z ${1} ]]; then | ||
Line 500: | Line 502: | ||
exit 1 | exit 1 | ||
fi | fi | ||
+ | |||
+ | ## Configure colors ## | ||
+ | # End/reset color | ||
+ | color_end=' | ||
+ | |||
+ | # Colors | ||
+ | color_green=' | ||
+ | color_red=' | ||
+ | color_yellow=' | ||
+ | ## End of configure colors ## | ||
# Set system name to the first argument | # Set system name to the first argument | ||
Line 509: | Line 521: | ||
# Send command to system and capture output | # Send command to system and capture output | ||
- | echo "-> Working on ${system_name}..." | ||
output=" | output=" | ||
+ | return_code=$(echo $?) | ||
- | # Show formatted | + | case " |
- | echo -e ">> Returned | + | 0) # 0 return code - show green return code |
+ | echo -e "-> ${system_name} (${color_green}retcode=${return_code}${color_end})\n${output}\n" | ||
+ | ;; | ||
+ | 1) # 1 return code - show red return code | ||
+ | | ||
+ | ;; | ||
+ | *) # any other return code - show yellow return code | ||
+ | echo -e " | ||
+ | ;; | ||
+ | esac | ||
</ | </ | ||
---- | ---- | ||