X-Git-Url: http://git.samba.org/samba.git/?p=ira%2Fwip.git;a=blobdiff_plain;f=examples%2Fscripts%2Fusers_and_groups%2Fcreatedomobj.pl;h=919f75ad07699f1445ba1e5367690c2d35044296;hp=4bcfb8edf3e29ba3bc70d56ed45c08f06adea7fd;hb=HEAD;hpb=67e79219dac4adbae437f46e144f2f09676d44bc diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 4bcfb8edf3e..919f75ad076 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -10,7 +10,7 @@ # # 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 @@ -19,8 +19,7 @@ # 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 . # # @@ -40,7 +39,7 @@ my $rpccli_cmd = "rpcclient"; 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; @@ -103,6 +102,8 @@ if (exists($options{n})) { if (exists($options{p})) { $prefix = $options{p}; +} else { + $prefix = $target_type; } if (exists($options{P})) { @@ -116,7 +117,7 @@ if (@ARGV) { exit 1; } -# rpc open/close functions: +# utility functions: sub open_rpc_pipe { print "opening rpc pipe\n"; @@ -129,20 +130,22 @@ sub close_rpc_pipe { 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(); @@ -151,5 +154,6 @@ else { } } } + close_rpc_pipe();