Jump to content
Sign in to follow this  

Compare and ignore text strings

Recommended Posts

I don't like posting queries like this as I feel its too specific to my own needs, but I'm kinda stuck and would appreciate the help.

I have this script:

; ----------------------------------------------------------------------------
; AutoIt Version: 3.0.101
; Language:       English
; Platform:       Win9x / NT
; Author:         Chris Stoneham
; Script Function:
;   Produce list of groups in batch file with syntax for NET GROUP command
;   Produce list of groups and members (comma and | delimited)
; ----------------------------------------------------------------------------

Global $inputFile="TEMP_ndsgroups.txt"
Global $outputFile="groups_memberslist.bat"
Global $output2File="populate_groups.bat"
Global $members=""

If MsgBox(4100,"Groups List","This script scans Novell for groups, then produces two output files;" & @LF & @LF &_
$output2File & @TAB & @TAB & "a batch file for creation of groups on Windows" & @LF &_
$outputFile & @TAB & "a list of groups and members (comma and | delimited)" & @LF & @LF & "Do you want to proceed?") = 6 Then

   If FileExists($inputFile) Then

      If MsgBox(4100,"File Conflict!",$inputFile & " already exists. Do you wish to use this?" & @LF & @LF &_
         "Press Yes to use this file, or No to over-write it") = 7 Then;NO
        ;run nlist command to output file (nlist group show member)
         SplashTextOn("Processing...",@LF & "Exporting Novell groups, please wait",400,100)
         RunWait(@ComSpec & " /c nlist group show member > " & $inputFile,@ScriptDir,@SW_HIDE)
      SplashTextOn("Processing...",@LF & "Exporting Novell groups, please wait",400,100)
      RunWait(@ComSpec & " /c nlist group show member > " & $inputFile,@ScriptDir,@SW_HIDE)
   SplashTextOn("Processing...",@LF & "Creating output files, please wait",400,100)
   FileWriteLine($o2File,"echo This batch file will create groups on Windows")
   FileWriteLine($oFile,"echo This batch file will populate groups on Windows")
   While 1
     If @error = -1 Then ExitLoop
     If StringInStr($line,"Name: ") > 0 Then
         If $members <> "" Then
            FileWriteLine($oFile,$members & "/ADD /DOMAIN")
         FileWrite($oFile,"NET GROUP " & $groupname & " ")
         FileWriteLine($o2File,"NET GROUP " & $groupname & " /ADD /DOMAIN");this line generates NET syntax for creating groups
      ElseIf StringInStr($line,"Member: ") > 0 Then
         $member=StringReplace($line,"Member: ","~")
         $members=$member & " " & $members
   MsgBox(4160,"Finished",$outputfile & " and " & $output2File & " have been created. Please check for accuracy.")

Func OpenFiles()
   Global $iFile
   Global $oFile
   Global $o2File
  ;Check if file opened for writing OK
   If $iFile = -1 Then
      MsgBox(0, "Error", "Unable to open Input file.")
  ;Check if file opened for writing OK
   If $oFile = -1 Then
      MsgBox(0, "Error", "Unable to open First Output file.")
  ;Check if file opened for writing OK
   If $o2File = -1 Then
      MsgBox(0, "Error", "Unable to open Second Output file.")

which parses a file in this format:

Name: GROUP1
    Member: USER1
    Member: USER2
    Member: USER3
Name: GROUP2
    Member: USER4
    Member: USER5
    Member: USER6

What I need is a way of setting up a kind of 'ignore list' of group names and if the name is in the list it doesn't get written to the output file.

Can anyone give me any pointers in the right direction?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...