项目作者: Anvil

项目描述 :
DSH with patterns, regexps.
高级语言: Shell
项目地址: git://github.com/Anvil/dtcsh.git
创建时间: 2017-02-08T08:24:33Z
项目社区:https://github.com/Anvil/dtcsh

开源协议:

下载


dtcsh

DSH with patterns, regexps.

What is it ?

dtcsh is a wrapper for
the dancer shell. It
allows user to specify host names by regular expressions, or specify
group names by pattern

It’s technically safe to do

  1. alias dsh=dtcsh

However, it still relies on the original dsh.

How to install it ?

Prerequisites

You need to install zsh, dsh, and cssh (for interactive shells) first of all.

Note that your cssh package is probably named clusterssh

dtcsh installation

Get (git clone, or copy) the dtcsh script from this repository, and place it somewhere in your $PATH.

Configuration

Just use dsh configuration.

Use man dsh.conf for detailled information.

DSH enhancements

Imagine you have multiple node00{1,2,3,…}.mydomain servers located in multiple group files and you want to contact them.

  1. # Instead of
  2. $ dsh -m node001.mydomain -m node002.mydomain -m .... uptime
  3. # Do this
  4. dtcsh -m 'node[0-9]+.mydomain' uptime

Or if there’s a pattern in group files :

  1. # Instead of
  2. $ dsh -g 'prod/node' -g 'dev/node' uptime
  3. # You can do this
  4. $ dtcsh h -g '*/node' ls

More features

Search for group files

  1. # All groups named node
  2. $ dtcsh ls '**/node'
  3. # All groups underneath prod subdir
  4. $ dtcsh ls 'prod/**/*'

All zsh extended patterns are allowed

Search for hostnames

  1. # You want to look for all hostnames containing keyword john
  2. $ dtcsh grep keyword

cssh wrapping

For people fond of interactivity, dtcsh can combine dsh groups power
with clusterssh.

  1. # Open an interactive shell on every node.
  2. $ dtcsh cssh 'node[0-9]+.mydomain'

More

  1. $ dtcsh -h
  2. DTCsh-wrapped Distributed Shell / Dancer's shell version 0.25.10
  3. Copyright 2001-2005 Junichi Uekawa,
  4. distributed under the terms and conditions of GPL version 2
  5. -v --verbose Verbose output
  6. -q --quiet Quiet
  7. -M --show-machine-names Prepend the host name on output
  8. -H --hide-machine-names Do not prepend host name on output
  9. -i --duplicate-input Duplicate input given to dsh
  10. -b --bufsize Change buffer size used in input duplication
  11. -m --machine [machinename] Execute on machine
  12. -n --num-topology How to divide the machines
  13. -a --all Execute on all machines
  14. -g --group [groupname] Execute on group member
  15. -f --file [file] Use the file as list of machines
  16. -r --remoteshell [shellname] Execute using shell (rsh/ssh)
  17. -o --remoteshellopt [option] Option to give to shell
  18. -h --help Give out this message
  19. -w --wait-shell Sequentially execute shell
  20. -c --concurrent-shell Execute shell concurrently
  21. -F --forklimit [fork limit] Concurrent with limit on number
  22. -V --version Give out version information
  23. Alternative syntaxes in which none of the above options apply:
  24. dtcsh ls 'group_pattern'
  25. Prints the dsh group names matching given pattern.
  26. dtcsh cat 'group_pattern'
  27. Prints the (uniq) hostnames contained in dsh group names
  28. matching given pattern.
  29. dtcsh match 'hostname_regexp' [ 'group' ]
  30. Prints dsh group names containing hostnames matching given 'grep
  31. -E'-styled regular expression. If given, 'group' represents the
  32. beginning of a dsh group name, restricting the research to that
  33. 'group' tree.
  34. dtcsh grep 'hostname_regexp' [ 'group' ]
  35. Same as the 'match' command, but prints matching host names (and
  36. not dsh groups) instead.
  37. dtcsh cssh [ <cssh option> ... ] '[login@](group|file|regexp|hostname)[:port]'
  38. Acts like cssh. Parameters can be either dsh groups, file names,
  39. hostname regular expression pattern or plain host names, with
  40. optional '<username>@' prefix and optional ':<port number>'
  41. suffix. If 'dtcsh' is called as 'cssh' or 'dcssh', 'dtcsh' acts
  42. as if called as 'dtcsh cssh'.
  43. dtcsh clean-keys '(group|regexp|hostname)'
  44. Remove entries from your ~/.ssh/known_hosts file. Parameters can be
  45. either dsh groups, hostname or hostname regular expressions. The
  46. IP address will also be removed from the known_hosts file.
  47. dtcsh update-keys '(group|regexp|hostname)'
  48. Like clean-keys action but also attempt to connect the expanded
  49. list of hostnames so that latest version of host keys will be
  50. re-added to the known_hosts file.
  51. dtcsh remove 'regexp'
  52. Removes all hostnames matching given regular expression from dsh
  53. groups.
  54. dtcsh whatever '(group|regexp|hostname)'
  55. Expands arguments into a list of host names, whatever their
  56. nature: group pattern, host name regular expression or plain host
  57. name. It's the exact same subroutines used in clean-keys,
  58. update-keys and in the cssh wrapper.