diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-09-24 09:02:59 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-09-24 09:02:59 +0300 |
commit | 333243970b1e1a933a1a4935fb75ec8347f3ba39 (patch) | |
tree | 2e554a57d5ffae161e92775ab6b4fb4afa00d05e | |
parent | 35a17ba8a9bfea11b9cb6cad3b4b1b057ee62f4f (diff) | |
download | rex-333243970b1e1a933a1a4935fb75ec8347f3ba39.tar.gz rex-333243970b1e1a933a1a4935fb75ec8347f3ba39.tar.bz2 |
Minor fixes
-rwxr-xr-x | rex | 225 | ||||
-rw-r--r-- | rex.man8 | 55 |
2 files changed, 138 insertions, 142 deletions
@@ -94,7 +94,7 @@ array set optiondef { return -code error "file $arg doesn't exist or is unreadable" } }} - + host,lambda { args { foreach a $args { lappend ::config(hosts) {*}[split $arg ","] @@ -131,7 +131,9 @@ array set optiondef { sudo,type bool sudo,lambda { arg setsudo } - + + tcl-trace,type bool + user,nargs 1 user,lambda { arg { set ::config(user) $arg }} @@ -2616,21 +2618,26 @@ namespace eval ::config { append locus ":" [dict get $options -errorline] } terror "$locus: $result" -# return -code 1 -options $options - foreach {tok prm} [dict get $options -errorstack] { - switch -- $tok { - {CALL} { - if {[lindex $prm 0] == "::config::read"} { - break - } - if {[info exists prevcall]} { - if {$prevcall == "prm"} { - continue + if {[config_option tcl-trace]} { + return -code error -options $options + } elseif {![dict exists $options -errorstack]} { + puts [dict get $options -errorinfo] + } else { + foreach {tok prm} [dict get $options -errorstack] { + switch -- $tok { + {CALL} { + if {[lindex $prm 0] == "::config::read"} { + break + } + if {[info exists prevcall]} { + if {$prevcall == "prm"} { + continue + } } + terror "called from:" + puts stderr "$prm" + set prevcall prm } - terror "called from:" - puts stderr "$prm" - set prevcall prm } } } @@ -2953,9 +2960,11 @@ proc rex_parse_cmdline {args} { # Process level 2 options catch_config_error {::getopt::run $parser mode } 1 -} - + if {[config_option noop]} { + exit 0 + } +} proc rex_command args { global argv0 @@ -2975,69 +2984,63 @@ proc rex_command args { -usage {rex run [OPTIONS] PROGRAM [ARGS...]} \ -docstring {Runs PROGRAM on the given hosts.} \ -group global { - group,g=NAME - {select host group} - { option_set group $optarg } + group,g=NAME + {select host group} + { option_set group $optarg } } \ -group mode { - buffer-output,b - {buffer output from servers} - { option_set buffer-output true } - confirm,w - {prompt and wait for confirmation before each host} - { option_set confirm true } - copy - {copy PROGRAM to each host before executing} - { option_set copy true} - data-file,D=FILE - {copy FILE to each host before running command} - { option_set data-file $optarg } - host,H=HOST - {add HOST to the host list} - { lappend ::config(hosts) {*}[split $optarg ","] } - exclude-host,X=HOST - {remove HOST from the host list} - { lappend ::config(exclude_hosts) {*}[split $optarg ","] } - ignore-hosts,i - {ignore the list of hosts read from the hostgroup file} - { option_set ignore-hosts true } - interactive,I - {interactively ask for missing usernames and passwords} - { option_set interactive true } - interpreter=PROGRAM - {use COMMAND as interpreter for running PROGRAM; implies --copy} - { option_set interpreter $optarg } - jobs,j=N - {run N jobs at once} - { option_set jobs $optarg } - no-host-header - {don't print hostname before output from the host} - { option_set no-host-header true } - password,p=PASS - {set password (unsafe!)} - { set ::config(pass) $optarg } - prefix,P - {prefix each output line with the server name or IP} - { option_set prefix true } - source,s=NAME - {source .rex/NAME.tcl} - { option_set source $optarg } - sudo - {run PROGRAM via sudo} - { option_set sudo true } - user,u=NAME - {log in as user NAME} - { set ::config(user) $optarg } - zsh-quirk,Z - {try to cope with hosts running zsh} - { option_set zsh-quirk true } - } - - # FIXME - if {[config_option noop]} { - updatedb - exit 0 - } + buffer-output,b + {buffer output from servers} + { option_set buffer-output true } + confirm,w + {prompt and wait for confirmation before each host} + { option_set confirm true } + copy + {copy PROGRAM to each host before executing} + { option_set copy true} + data-file,D=FILE + {copy FILE to each host before running command} + { option_set data-file $optarg } + host,H=HOST + {add HOST to the host list} + { lappend ::config(hosts) {*}[split $optarg ","] } + exclude-host,X=HOST + {remove HOST from the host list} + { lappend ::config(exclude_hosts) {*}[split $optarg ","] } + ignore-hosts,i + {ignore the list of hosts read from the hostgroup file} + { option_set ignore-hosts true } + interactive,I + {interactively ask for missing usernames and passwords} + { option_set interactive true } + interpreter=PROGRAM + {use COMMAND as interpreter for running PROGRAM; implies --copy} + { option_set interpreter $optarg } + jobs,j=N + {run N jobs at once} + { option_set jobs $optarg } + no-host-header + {don't print hostname before output from the host} + { option_set no-host-header true } + password,p=PASS + {set password (unsafe!)} + { set ::config(pass) $optarg } + prefix,P + {prefix each output line with the server name or IP} + { option_set prefix true } + source,s=NAME + {source .rex/NAME.tcl} + { option_set source $optarg } + sudo + {run PROGRAM via sudo} + { option_set sudo true } + user,u=NAME + {log in as user NAME} + { set ::config(user) $optarg } + zsh-quirk,Z + {try to cope with hosts running zsh} + { option_set zsh-quirk true } + } debug 2 "running prologue script" ::hostproc::prologue @@ -3216,19 +3219,24 @@ proc rex_copy_from {} { rex_parse_cmdline \ -usage {rex rcp|copy-from [OPTIONS] HOST FILE [FILE...] DEST} \ -docstring {Copies FILEs from HOST to DEST on the local machine.} \ + -group global { + group,g=NAME + {select host group} + { option_set group $optarg } + } \ -group mode { - interactive,I - {interactively ask for missing usernames and passwords} - { option_set interactive true } + interactive,I + {interactively ask for missing usernames and passwords} + { option_set interactive true } - password,p=PASS - {set password (unsafe!)} - { set ::config(pass) $optarg } + password,p=PASS + {set password (unsafe!)} + { set ::config(pass) $optarg } - user,u=NAME - {log in as user NAME} - { set ::config(user) $optarg } - } + user,u=NAME + {log in as user NAME} + { set ::config(user) $optarg } + } if {$argc < 3} { terror "too few arguments for copy-from" @@ -3332,27 +3340,32 @@ proc rex_login {} { rex_parse_cmdline \ -usage {rex login [OPTIONS] HOST} \ -docstring {Log in to HOST.} \ + -group global { + group,g=NAME + {select host group} + { option_set group $optarg } + } \ -group mode { - interactive,I - {interactively ask for missing usernames and passwords} - { option_set interactive true } + interactive,I + {interactively ask for missing usernames and passwords} + { option_set interactive true } - password,p=PASS - {set password (unsafe!)} - { set ::config(pass) $optarg } + password,p=PASS + {set password (unsafe!)} + { set ::config(pass) $optarg } - user,u=NAME - {log in as user NAME} - { set ::config(user) $optarg } + user,u=NAME + {log in as user NAME} + { set ::config(user) $optarg } - zsh-quirk,Z - {try to cope with hosts running zsh} - { option_set zsh-quirk true } + zsh-quirk,Z + {try to cope with hosts running zsh} + { option_set zsh-quirk true } - sudo - {run PROGRAM via sudo} - setsudo - } + sudo + {run PROGRAM via sudo} + setsudo + } if {$argc == 0} { terror "hostname is required in login mode" @@ -3582,6 +3595,10 @@ Report bugs to <gray+rex@gnu.org.ua> {don't resolve IP addresses when printing hostnames} { set ::config(option,resolve) 0 } + tcl-trace,T + {dump full TCL traces on errors} + { option_set tcl-trace true } + version,V {print program version and copyright statement} prversion @@ -13,7 +13,7 @@ .\" .\" You should have received a copy of the GNU General Public License .\" along with Rex. If not, see <http://www.gnu.org/licenses/>. -.TH REX 8 "September 23, 2016" "REX" "Rex User Reference" +.TH REX 8 "September 24, 2016" "REX" "Rex User Reference" .ds ET /etc .SH NAME rex \- remote execution utility @@ -279,43 +279,11 @@ given preference over the system-wide. The only mandatory file is separate namespace, to avoid the possibility of inadvertent contamination of the main \fBrex\fR code. .PP -The global variables available for modification in the \fBrc\fR file -are: -.TP -.B hosts -A list of hostnames or IP addresses of the hosts that comprise the -hostgroup. E.g.: -.sp -.RS -.EX -set hosts [list one.example.com two.example.com] -.EE -.RE -.TP -.B description -A one-line textual description of the group. It is displayed by the -\fBrex list\fR command. If not defined, the description is -read from the first line of file \fB~/.rex/\fINAME\fB/description\fR, -if this file exists. -.TP -.B user -Default user name. It is the login name that will be used in the -absence of the login name defined for that particular host. See the -subsection \fBLogin credentials\fR, for more information. This -setting is overridden by the \fB\-u\fR (\fB\-\-user\fR) command line -option. -.TP -.B password -Default password. See the subsection \fBLogin credentials\fR, for -more information. -.TP -.B command -Command to run on the hosts in this hostgroup (an array). It is used -if no command is given in the command line. -.TP -.B sudo -Boolean. \fB1\fR if the command must be run via -.BR sudo . +\fBRex\fR provides a set of basic commands for use in rc files, so +normally there is no need to know \fBrex\fR internals in order to +configure it. See the subsection +.B Configuration files +for a detailed guide. .SS Debugging To see what's going on during \fBrex\fR invocation. Use the \fB\-d (\fB\-\-debug\fR) option. This option is incremental, that is @@ -336,6 +304,13 @@ variable is the name of a file where to output additional information (as well as showing it on the standard error). Overall effect is equivalent to setting \fBexp_internal\fR in .BR expect . +.PP +When \fBrex\fR encounters an error in one of its rc files, it prints +the location where the error occurred and a short diagnostic message +describing the nature of the error. If you wish to obtain full trace +of TCL calls for such errors, use the +.B \-\-tcl\-trace +option. Normally, this option is only useful for \fBrex\fR developers. .SH OPTIONS .TP \fB\-c\fR, \fB\-\-config=\fIFILE\fR @@ -356,6 +331,10 @@ Ignore all commands (useful for side effects). .BR \-n ", " \-\-no\-resolve Don't resolve IP addresses when printing hostnames. .TP +.B \-\-tcl\-trace +Produce full TCL trace if an error occurs while sourcing one of the +configuration files. This option is useful mainly for developers. +.TP \fB\-v\fR, \fB\-\-verbose\fR Enable additional warnings. .TP |