Pages

3/25/2002

CONVERT NOVELL ADDRESS BOOK TO OUTLOOK

#NAB2CSV.PL
#3/20/2002
#convert Novell NAB formatted file to CSV file that can be imported into Outlook

#filenames & variables
$indir = 'c:\\work\\nab2csv\\nab';
$outdir = 'c:\\work\\nab2csv\\csv';

#Expressions to filter
my @filter = (
"^:::TAGMAP:::" ,
"CONVAPI" ,
"ICEMILLER\.COM" ,
"\.IMDR" ,
"OFFICE\.VENUS" ,
"first administrative group" ,
"^\"G>" ,
"^\"G<" ,
"^\"GT"
);


opendir(DIR, "$indir");
my @files = readdir(DIR);
closedir(DIR);

my $file;
my $keep;

foreach $file (@files) {
if ($file eq ".") {next};
if ($file eq "..") {next};
#input filename
my $infile = "$indir\\$file";
#output filename
my $newfile = $file;
$newfile =~ s/.NAB$/.CSV/gi;
$newfile = "$outdir\\$newfile";
open (OUT, ">$newfile");
#output NAB header to file
print OUT "::TAGMAP:::0FFE0003:***,Name,Business Phone,Department,Business Fax,E-Mail Address,First Name,Last Name,Title,Business Street,Business City,Business State,Business Country,Business Postal Code,E-Mail Type,Mailstop,Home Phone,Cellular Phone Number,Phone Number,Greeting,Owner,Company,Comments,User ID,Domain,Additional Routing,Post Office,GUID,NDS Distinguished Name,Network ID,\n";

open(LINES, "<$infile") or ( die "File error in:$infile");
my @lines = ;
close (LINES);

foreach $line (@lines) {
$keep = "yes";
foreach $filter (@filter) {
if ($line=~/$filter/gi) {
$keep = "no";
last;
}#end if $filter
}#end foreach $filter

if ($keep eq "yes") {
$line =~ s/INTERNET://gi; #remove INTERNET: prefix
$line =~ s/^\"UT\"/\"U\"/i; #make dist list entries user entries
print OUT $line;
}#end if $keep

}#end foreach $line
close (OUT);#close output file
}#end foreach $file

3/20/2002

Learn Perl: Perl Q&A: How do I do fill-in-the-blank for every file in a directory?
Anatomy of a perl one-line substitution command
perl -i[.backup-extension] -p -e 's#pat1#pat2#ig' files

-i[.backup-extension]
Tells perl to run the command on the named files in-place, i.e., using the named files both as input and output. If a backup extension is provided, the unmodified version of each file will be saved with the extension appended.
Example: -i.bak
-p
Tells perl to assume an input loop around your one-line program and echo the output.
-e
The one-line program follows.
's#pat1#pat2#ig'
The perl "substitution" function. Matches every instance of the pattern pat1 and replaces it with pat2. The "#" used to delimit the patterns can be any character that isn't found in pat1 or pat2. The perl pattern matching used in pat1 is very powerful and somewhat complex; the main pitfall to remember is that you may need to escape special characters such as "." with a preceding backslash, e.g. "xyz\.rice\.edu". The trailing "i" flag means to ignore case when matching pat1. The trailing "g" flag means to apply the substitution multiple times on the same line (without the "g" it will only be applied to the leftmost pattern match on each line).
files
The file(s) on which the command should be run. In an HTML context, you probably want to specify a pattern in the shell to match your HTML files, taking into account any subdirectories you also want to include. Examples:
*.html

3/13/2002

Windows 2000 Domain Controller Operations Master Roles How do I find out what server holds what role?
Probably the easiest method is to use the W2K version of netdom:
netdom query fsmo
Tips for Windows 2000 NT Administrators Wayne's Windows 2000 NT Administrator Tips
Excellent resource. It has good summaries of information relevant to best practices and administration.
Windows 2000 Domain Controller Operations Master Roles Admin Tip #56: Windows 2000 Domain Controller Operations Master Roles