added new veriosn of admin manual
[spider.git] / perl / export_user.pl
1 #!/usr/bin/perl
2 #
3 # Export the user file in a form that can be directly imported
4 # back with a do statement
5 #
6
7 require 5.004;
8
9 # search local then perl directories
10 BEGIN {
11         # root of directory tree for this system
12         $root = "/spider"; 
13         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
14         
15         unshift @INC, "$root/perl";     # this IS the right way round!
16         unshift @INC, "$root/local";
17 }
18
19 use DXVars;
20 use DXUser;
21
22 $userfn = $ARGV[0] if @ARGV;
23
24 DXUser->init($userfn);
25
26 @all = DXUser::get_all_calls();
27 $t = scalar localtime;
28 print "#!/usr/bin/perl
29 #
30 # The exported userfile for a DXSpider System
31
32 # Input file: $userfn
33 #       Time: $t
34 #
35
36 package DXUser;
37
38 %u = (
39 ";
40
41 for $a (@all) {
42         my $ref = DXUser->get($a);
43         if (ref $ref) {
44                 my $s = $ref->encode();
45         
46                 print "'$a' => q{ $s },\n";
47         } else {
48                 print "# $a has gorn missing\n";
49         }
50         $count++;
51 }
52 print ");\n
53 #
54 # there were $count records
55 #\n";
56