#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
+# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# more details.
#
# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 675
-# Mass Ave, Cambridge, MA 02139, USA.
+# this program; if not, see <http://www.gnu.org/licenses/>.
#
#
my $server;
my $num_targets = 1;
my $startnum; # if empty, don't add numbers to prefix
-my $prefix = $target_type; # name-prefix
+my $prefix; # name-prefix
my $path; # path to rpcclient command
my $rpccli_path = $rpccli_cmd;
my $creds;
if (exists($options{p})) {
$prefix = $options{p};
+} else {
+ $prefix = $target_type;
}
if (exists($options{P})) {
exit 1;
}
-# rpc open/close functions:
+# utility functions:
sub open_rpc_pipe {
print "opening rpc pipe\n";
close(IPC);
}
+sub do_create {
+ my $target_name = shift;
+ print "creating $target_type $target_name\n";
+ print IPC "$rpc_cmd $target_name\n";
+}
+
# main:
open_rpc_pipe();
if ("x$startnum" eq "x") {
- my $target_name = $prefix;
- print "creating $target_type $target_name\n";
- print IPC "$rpc_cmd $target_name\n";
+ do_create($prefix);
}
else {
for (my $num = 1; $num <= $num_targets; ++$num) {
- my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1;
- print "creating $target_type $target_name\n";
- print IPC "$rpc_cmd $target_name\n";
+ do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1);
if (($num) % 500 == 0) {
printf("500 ".$target_type."s created\n");
close_rpc_pipe();
}
}
}
+
close_rpc_pipe();