Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge from atnodes

  • Loading branch information...
commit 6f89ec80b3f5ad009fb66f795f774e0a261ef3c9 2 parents d7d5aa3 + 94cfb18
@liseen liseen authored
View
10 Changes
@@ -2,6 +2,16 @@
- atnodes: clean tmp file
- atnodes: check openssh version >= 4.1
+0.027
+- added support for the environment SSH_BATCH_RC to specify a
+ different file name than the default ~/.fornodesrc.
+ thanks Mithun Ayachit.
+- updated host variable format check to /\w[-\.\w]*/.
+- added the SSH_BATCH_PASSPHRASE environment for -P and
+ SSH_BATCH_PASSWORD env for -w.
+- added passphrase support.
+- added some doc for tty option.
+
0.025
- update variable format check to \w[-\.\w]*
- added SSH_BATCH_PASSPHRASE for -P and SSH_BATCH_PASSWORD env for -w
View
4 META.yml
@@ -1,7 +1,7 @@
---
abstract: 'Cluster operations based on parallel SSH, set and interval arithmetic'
author:
- - 'Agent Zhang <agentzh@yahoo.cn>'
+ - "Zhang \"agentzh\" Yichun <agentzh@gmail.com>"
build_requires:
ExtUtils::MakeMaker: 6.42
IPC::Run3: 0
@@ -30,4 +30,4 @@ requires:
resources:
license: http://opensource.org/licenses/bsd-license.php
repository: http://github.com/agentzh/sshbatch
-version: 0.026
+version: 0.027
View
2  Makefile.PL
@@ -4,7 +4,7 @@ use inc::Module::Install;
name ('SSH-Batch');
license ('bsd');
-author ('Agent Zhang <agentzh@yahoo.cn>');
+author ('Zhang "agentzh" Yichun <agentzh@gmail.com>');
perl_version ('5.006001');
all_from ('lib/SSH/Batch.pm');
View
39 README
@@ -3,7 +3,7 @@ NAME
arithmetic
VERSION
- This document describes SSH::Batch 0.024 released on Nov 1, 2010.
+ This document describes SSH::Batch 0.027 released on 25 August 2011.
SYNOPSIS
The following scripts are provided:
@@ -47,9 +47,6 @@ SYNOPSIS
# or prompt for password if sudo required...
$ atnodes 'sudo apachectl restart' '{ps}' -w
- # use -P to prompt for passphrase (no echo back)
- $ atnodes hostname '{ps}' -u agentz -P
-
# run sudo command if tty required...
$ atnodes -tty 'sudo apachectl restart' '{ps}'
@@ -83,7 +80,8 @@ DESCRIPTION
operations: fornodes, atnodes, tonodes, and key2nodes.
"SSH::Batch" allows you to name your clusters using variables and
- interval/set syntax in your ~/.fornodesrc config file. For instance:
+ interval/set syntax in your ~/.fornodesrc config file (or a different
+ file name specified by the "SSH_BATCH_RC" environment). For instance:
$ cat ~/.fornodesrc
A=foo[01-03].com bar.org
@@ -260,6 +258,15 @@ TIPS
$ atnodes 'ls -lh' '{B} + bob@bar[29-31].org:5678'
+ It's also possible to specify a different rc config file than
+ ~/.fornodesrc via the environment variable "SSH_BATCH_RC". For
+ example,
+
+ export SSH_BATCH_RC=/opt/my-fornodes-rc
+
+ then the file /opt/my-fornodes-rc will be used instead of the
+ default ~/.fornodesrc file.
+
Use "-L" to help grepping the outputs by hostname
When managing hundreds or even thousands of machines, it's often
more convenient to "grep" over the outputs of atnodes or tonodes by
@@ -345,11 +352,11 @@ INSTALLATION
Win32 users should replace "make" with "nmake".
-SOURCE CONTROL
- You can always get the latest SSH::Batch source from its public Git
+CODE REPOSITORY
+ You can always get the latest "SSH::Batch" source from its public Git
repository:
- http://github.com/agentzh/sshbatch/tree/master
+ <http://github.com/agentzh/sshbatch>
If you have a branch for me to pull, please let me know ;)
@@ -366,17 +373,19 @@ TODO
* Add the betweennodes script to transfer files between clusters
through localhost.
-SEE ALSO
- fornodes, atnodes, tonodes, key2nodes, SSH::Batch::ForNodes,
- Net::OpenSSH.
+AUTHORS
+ * Zhang "agentzh" Yichun (章亦春) "<agentzh@gmail.com>"
-COPYRIGHT AND LICENSE
+ * Liseen Wan (万珣新) "<liseen.wan@gmail.com>"
+
+COPYRIGHT & LICENSE
This module as well as its programs are licensed under the BSD License.
Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights
reserved.
- Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+ Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights
+ reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -406,3 +415,7 @@ COPYRIGHT AND LICENSE
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+SEE ALSO
+ fornodes, atnodes, tonodes, key2nodes, SSH::Batch::ForNodes,
+ Net::OpenSSH.
+
View
24 bin/atnodes
@@ -10,7 +10,6 @@ use Term::ReadKey;
use SSH::Batch::ForNodes;
use File::Temp qw/ :POSIX /;
use Time::HiRes qw/sleep/;
-use IPC::Open3;
sub help ($);
sub check_openssh_version ($);
@@ -316,6 +315,7 @@ _EOC_
}
}
+<<<<<<< HEAD
sub check_openssh_version ($) {
my $ssh_cmd = shift;
@@ -328,8 +328,12 @@ sub check_openssh_version ($) {
}
}
+=======
+>>>>>>> 94cfb1830ce1483c564184835923436b1e4bdfce
__END__
+=encoding utf-8
+
=head1 NAME
atnodes - Run commands on clusters
@@ -414,13 +418,27 @@ Please refer to L<SSH::Batch> for more documentation.
L<fornodes>, L<tonodes>, L<key2nodes>, L<SSH::Batch>, L<Net::OpenSSH>.
-=head1 COPYRIGHT AND LICENSE
+=head1 AUTHORS
+
+=over
+
+=item *
+
+Zhang "agentzh" Yichun (章亦春) C<< <agentzh@gmail.com> >>
+
+=item *
+
+Liseen Wan (万珣新) C<< <liseen.wan@gmail.com> >>
+
+=back
+
+=head1 COPYRIGHT & LICENSE
This module as well as its programs are licensed under the BSD License.
Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved.
-Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
View
26 bin/fornodes
@@ -67,6 +67,8 @@ _EOC_
__END__
+=encoding utf-8
+
=head1 NAME
fornodes - Expand patterns to machine host list
@@ -101,17 +103,27 @@ fornodes - Expand patterns to machine host list
Please refer to L<SSH::Batch> for more documentation.
-=head1 SEE ALSO
+=head1 AUTHORS
-L<key2nodes>, L<atnodes>, L<tonodes>, L<SSH::Batch>, L<Net::OpenSSH>.
+=over
+
+=item *
+
+Zhang "agentzh" Yichun (章亦春) C<< <agentzh@gmail.com> >>
+
+=item *
+
+Liseen Wan (万珣新) C<< <liseen.wan@gmail.com> >>
+
+=back
-=head1 COPYRIGHT AND LICENSE
+=head1 COPYRIGHT & LICENSE
This module as well as its programs are licensed under the BSD License.
-Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved.
+Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc.
-Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春).
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -133,3 +145,7 @@ Neither the name of the Yahoo! China EEEE Works, Alibaba Inc. nor the names of i
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+=head1 SEE ALSO
+
+L<key2nodes>, L<atnodes>, L<tonodes>, L<SSH::Batch>, L<Net::OpenSSH>.
+
View
4 bin/key2nodes
@@ -253,6 +253,8 @@ _EOC_
}
__END__
+=encoding utf-8
+
=head1 NAME
key2nodes - Push SSH public keys to remote clusters
@@ -305,7 +307,7 @@ This module as well as its programs are licensed under the BSD License.
Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved.
-Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
View
24 bin/tonodes
@@ -375,6 +375,8 @@ _EOC_
}
__END__
+=encoding utf-8
+
=head1 NAME
tonodes - Upload local files/directories to remote clusters
@@ -428,17 +430,27 @@ tonodes - Upload local files/directories to remote clusters
Please refer to L<SSH::Batch> for more documentation.
-=head1 SEE ALSO
+=head1 AUTHORS
-L<fornodes>, L<atnodes>, L<SSH::Batch>, L<key2nodes>, L<Net::OpenSSH>.
+=over
+
+=item *
+
+Zhang "agentzh" Yichun (章亦春) C<< <agentzh@gmail.com> >>
+
+=item *
+
+Liseen Wan (万珣新) C<< <liseen.wan@gmail.com> >>
+
+=back
-=head1 COPYRIGHT AND LICENSE
+=head1 COPYRIGHT & LICENSE
This module as well as its programs are licensed under the BSD License.
Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved.
-Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -460,3 +472,7 @@ Neither the name of the Yahoo! China EEEE Works, Alibaba Inc. nor the names of i
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+=head1 SEE ALSO
+
+L<fornodes>, L<atnodes>, L<SSH::Batch>, L<key2nodes>, L<Net::OpenSSH>.
+
View
47 lib/SSH/Batch.pm
@@ -1,20 +1,24 @@
+# vim:set ft=perl ts=4 sw=4 et
+
package SSH::Batch;
use strict;
use warnings;
-our $VERSION = '0.025';
+our $VERSION = '0.027';
1;
__END__
+=encoding utf-8
+
=head1 NAME
SSH::Batch - Cluster operations based on parallel SSH, set and interval arithmetic
=head1 VERSION
-This document describes SSH::Batch 0.024 released on Nov 1, 2010.
+This document describes SSH::Batch 0.027 released on 25 August 2011.
=head1 SYNOPSIS
@@ -95,7 +99,7 @@ System administration (sysadmin) is also part of my C<$work>. Playing with a (bi
This is a high-level abstraction over the powerful L<Net::OpenSSH> module. A bunch of handy scripts are provided to simplify big cluster operations: L<fornodes>, L<atnodes>, L<tonodes>, and L<key2nodes>.
-C<SSH::Batch> allows you to name your clusters using variables and interval/set syntax in your F<~/.fornodesrc> config file. For instance:
+C<SSH::Batch> allows you to name your clusters using variables and interval/set syntax in your F<~/.fornodesrc> config file (or a different file name specified by the C<SSH_BATCH_RC> environment). For instance:
$ cat ~/.fornodesrc
A=foo[01-03].com bar.org
@@ -246,6 +250,12 @@ You may have already learned that you can use the C<-u> and C<-p> options to spe
$ atnodes 'ls -lh' '{B} + bob@bar[29-31].org:5678'
+It's also possible to specify a different rc config file than F<~/.fornodesrc> via the environment variable C<SSH_BATCH_RC>. For example,
+
+ export SSH_BATCH_RC=/opt/my-fornodes-rc
+
+then the file F</opt/my-fornodes-rc> will be used instead of the default F<~/.fornodesrc> file.
+
=item Use C<-L> to help grepping the outputs by hostname
When managing hundreds or even thousands of machines, it's often more
@@ -333,12 +343,11 @@ There's no spesial requirement on the server side ssh service. Even a non-OpenSS
Win32 users should replace "make" with "nmake".
-=head1 SOURCE CONTROL
+=head1 CODE REPOSITORY
-You can always get the latest SSH::Batch source from its
-public Git repository:
+You can always get the latest C<SSH::Batch> source from its public Git repository:
- http://github.com/agentzh/sshbatch/tree/master
+L<http://github.com/agentzh/sshbatch>
If you have a branch for me to pull, please let me know ;)
@@ -367,18 +376,27 @@ localhost.
=back
-=head1 SEE ALSO
+=head1 AUTHORS
-L<fornodes>, L<atnodes>, L<tonodes>, L<key2nodes>,
-L<SSH::Batch::ForNodes>, L<Net::OpenSSH>.
+=over
+
+=item *
-=head1 COPYRIGHT AND LICENSE
+Zhang "agentzh" Yichun (章亦春) C<< <agentzh@gmail.com> >>
+
+=item *
+
+Liseen Wan (万珣新) C<< <liseen.wan@gmail.com> >>
+
+=back
+
+=head1 COPYRIGHT & LICENSE
This module as well as its programs are licensed under the BSD License.
Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved.
-Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -400,3 +418,8 @@ Neither the name of the Yahoo! China EEEE Works, Alibaba Inc. nor the names of i
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+=head1 SEE ALSO
+
+L<fornodes>, L<atnodes>, L<tonodes>, L<key2nodes>,
+L<SSH::Batch::ForNodes>, L<Net::OpenSSH>.
+
View
42 lib/SSH/Batch/ForNodes.pm
@@ -1,9 +1,11 @@
+# vim:set ft=perl ts=4 sw=4 et
+
package SSH::Batch::ForNodes;
use strict;
use warnings;
-our $VERSION = '0.024';
+our $VERSION = '0.027';
use Set::Scalar;
use File::HomeDir;
@@ -27,14 +29,14 @@ sub clear_universe () {
}
sub init_rc () {
- my $rcfile = $ENV{SSH_BATCH_RC} || q();
- if(! $rcfile){
- my $home = $ENV{SSH_BATCH_HOME} || File::HomeDir->my_home;
- if (!defined $home || !-d $home) {
- die "Can't find the home for the current user.\n";
- }
- $rcfile = "$home/.fornodesrc";
- }
+ my $rcfile = $ENV{SSH_BATCH_RC} || q();
+ if(! $rcfile){
+ my $home = $ENV{SSH_BATCH_HOME} || File::HomeDir->my_home;
+ if (!defined $home || !-d $home) {
+ die "Can't find the home for the current user.\n";
+ }
+ $rcfile = "$home/.fornodesrc";
+ }
# auto create $rcfile if $rcfile not exists
if (! -e $rcfile) {
@@ -275,6 +277,8 @@ sub expand_wildcards ($) {
1;
__END__
+=encoding utf-8
+
=head1 NAME
SSH::Batch::ForNodes - Expand set arithmetic expression to host list
@@ -285,23 +289,35 @@ SSH::Batch::ForNodes - Expand set arithmetic expression to host list
use SSH::Batch::ForNodes;
SSH::Batch::ForNodes::init_rc();
+ # read the config file from env SSH_BATCH_RC or directly ~/.fornodesrc
+
my $set = SSH::Batch::ForNodes::parse_expr($expr);
# set is a Set::Scalar instance:
for my $host (sort $set->elements) {
print "$host\n";
}
-=head1 AUTHOR
+=head1 AUTHORS
+
+=over
+
+=item *
+
+Zhang "agentzh" Yichun (章亦春) C<< <agentzh@gmail.com> >>
-Agent Zhang (agentzh) C<< <agentzh@yahoo.cn> >>
+=item *
+
+Liseen Wan (万珣新) C<< <liseen.wan@gmail.com> >>
+
+=back
-=head1 COPYRIGHT AND LICENSE
+=head1 COPYRIGHT & LICENSE
This module as well as its programs are licensed under the BSD License.
Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved.
-Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved.
+Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Please sign in to comment.
Something went wrong with that request. Please try again.