Hello Brano,

An archeological dig discovered that on Thursday, October 18, 2001 at
10:06 GMT +0200, Brano [B] typed the following:

B> I needed to upgrade my Windows scripting host (scripten.exe),
B> now it work !

That's great.

B> It is pitty, when adding mail do adressbook - it doesnt
B> add any name, only mail adress. Name could be same as mail adress.

That can easily be changed.  After all, the script defines what goes
into the LDIF file, so we can add the name part too.  The version
pasted below adds the address as the name as well, though we could
change that to just the username part of the address if you prefer.
This version also does a little cleanup of the temp files it uses.

<begin script>
'/==========================================================/'
'/ Process Mail Delivery Subsystem failures                 /'
'/    Written by Januk Aggarwal                             /'
'/    October 2001                                          /'
'/==========================================================/'
  Dim TB, AB, CmdLine
  TB = """c:\Program Files\The Bat!\thebat.exe"""
  AB = "AB=""Blackbook"""
  CmdLine = TB & " /ImportLDIF;" & AB

'/----------------------------------------------------------/'
'/ Regexp function to test for fatal error message          /'
'/----------------------------------------------------------/'
  Function FatalErr( strTest )
    Dim regex, ptrn
    Set regex = New RegExp

    ptrn = "\s*\-{5}\s*The\sfollowing\saddresses\shad\s"
    ptrn = ptrn & "permanent\sfatal\serrors\s*\-{5}\s*"

    regex.IgnoreCase = True
    regex.Global = True
    regex.Pattern = ptrn

    FatalErr = regex.Test( strTest )
  End Function

'/----------------------------------------------------------/'
'/ Regexp function to extract the address                   /'
'/----------------------------------------------------------/'
  Function GetAddr( strTest )
    Dim regex, ptrn, match, matches
    Set regex = New RegExp

    ptrn = "\<(.*)\>"
    regex.IgnoreCase = True
    regex.Global = True
    regex.Pattern = ptrn

    Set matches = regex.Execute( strTest )
    Set match   = matches(0)
    GetAddr     = match.SubMatches(0)
  End Function

'/----------------------------------------------------------/'
'/ Get File name of file to analyze                         /'
'/----------------------------------------------------------/'
  Function GetName
    Dim objArgs, I
    Set objArgs = WScript.Arguments

    GetName = objArgs(0)
  End Function

'/----------------------------------------------------------/'
'/ Main Program                                             /'
'/----------------------------------------------------------/'
  Dim fso, WShell
  Set fso    = CreateObject("Scripting.FileSystemObject")
  Set WShell = CreateObject("WScript.Shell")

  Dim objInFname, objInFile, objOutFname, objOutFile
  objOutFname = "bb.ldif"
  objInFname  = GetName
  Set objInFile   = fso.OpenTextFile   ( objInFname  )
  Set objOutFile  = fso.CreateTextFile ( objOutFname )
  Set objInFname  = fso.GetFile        ( objInFname  )
  Set objOutFname = fso.GetFile        ( objOutFname )

  Dim strLine, strAddr, strOut
  Do While Not objInFile.AtEndOfStream
    strLine = objInFile.ReadLine

    If FatalErr( strLine ) Then
      strLine = objInFile.ReadLine
      strAddr = GetAddr( strLine )
 
      strOut = "dn: cn=" & strAddr
      strOut = strOut & ",mail="   & strAddr & vbCRLF
      strOut = strOut & "cn: " & strAddr & vbCRLF
      strOut = strOut & "mail: " & strAddr & vbCRLF
      strOut = strOut & "objectclass: top" & vbCRLF
      strOut = strOut & "objectclass: person"

      objOutFile.WriteLine( strOut )

      CmdLine = CmdLine & ";I=""" & objOutFname.Path & """"
      WShell.Run CmdLine, 8, True
      
      Exit Do
    End If
  Loop
  
  objInFile.Close ()
  objOutFile.Close()
  
  objInFname.Delete ( True )
  objOutFname.Delete( True )
<end script>

-- 
Thanks for writing,
 Januk Aggarwal

Using The Bat! 1.54/10 under Windows 98 4.10 Build 2222 A

I had a really great tagline to put here, but I can't remember what it
was.


-- 
______________________________________________________
Archives   : http://tbtech.thebat.dutaint.com
Moderators : mailto:[EMAIL PROTECTED]
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to