Windows Vista Forums

VB Script that searches a file for different text, with an append.
  1. #1


    njmike Guest

    VB Script that searches a file for different text, with an append.

    I'm trying to do the following and not having much luck.

    I need a script that opens a text log, once opened it searches for a unique
    identifyer that resides near the top of the file and looks something like
    this:

    "running with process name
    USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only really
    interested in the "server55" piece, but can make due with the entire string.



    The script then needs to continue parsing the file for error conditions
    which look like this:

    "There is/are 1 thread(s) in total in the server that may be hung"

    There could be multiple instances of that error message.

    What I would like to do is write to a seperate file the uniqueID, pluss
    error message, something similiar to this:

    There is/are 1 thread(s) in total in the server that may be hung on server55.


    Any assistance would be greatly appreciated.

    Regards,

    Mike


      My System SpecsSystem Spec

  2. #2


    Pegasus \(MVP\) Guest

    Re: VB Script that searches a file for different text, with an append.


    "njmike" <njmike@xxxxxx> wrote in message
    news:A0DC18CE-BF54-4C1E-A78F-32D7A4676F22@xxxxxx

    > I'm trying to do the following and not having much luck.
    >
    > I need a script that opens a text log, once opened it searches for a
    > unique
    > identifyer that resides near the top of the file and looks something like
    > this:
    >
    > "running with process name
    > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only really
    > interested in the "server55" piece, but can make due with the entire
    > string.
    >
    > The script then needs to continue parsing the file for error conditions
    > which look like this:
    >
    > "There is/are 1 thread(s) in total in the server that may be hung"
    >
    > There could be multiple instances of that error message.
    >
    > What I would like to do is write to a seperate file the uniqueID, pluss
    > error message, something similiar to this:
    >
    > There is/are 1 thread(s) in total in the server that may be hung on
    > server55.
    >
    >
    > Any assistance would be greatly appreciated.
    >
    > Regards,
    >
    > Mike
    >
    Let's have a look at what you've got so far. We can probably built in that.



      My System SpecsSystem Spec

  3. #3


    njmike Guest

    Re: VB Script that searches a file for different text, with an app



    "Pegasus (MVP)" wrote:

    >
    > "njmike" <njmike@xxxxxx> wrote in message
    > news:A0DC18CE-BF54-4C1E-A78F-32D7A4676F22@xxxxxx

    > > I'm trying to do the following and not having much luck.
    > >
    > > I need a script that opens a text log, once opened it searches for a
    > > unique
    > > identifyer that resides near the top of the file and looks something like
    > > this:
    > >
    > > "running with process name
    > > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only really
    > > interested in the "server55" piece, but can make due with the entire
    > > string.
    > >
    > > The script then needs to continue parsing the file for error conditions
    > > which look like this:
    > >
    > > "There is/are 1 thread(s) in total in the server that may be hung"
    > >
    > > There could be multiple instances of that error message.
    > >
    > > What I would like to do is write to a seperate file the uniqueID, pluss
    > > error message, something similiar to this:
    > >
    > > There is/are 1 thread(s) in total in the server that may be hung on
    > > server55.
    > >
    > >
    > > Any assistance would be greatly appreciated.
    > >
    > > Regards,
    > >
    > > Mike
    > >
    >
    > Let's have a look at what you've got so far. We can probably built in that.
    >
    > Appreciate your time Pegasus, Here's what I have so far:
    Const ForReading = 1

    Set objFSo = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("testIn.txt")

    Do Until objFile.AtEndOfStream
    strText = objFile.ReadLine
    If InStr(strText, "running with process name") Then
    arrText = Split(strText, "and process id")
    strVariable = arrText(0)
    'Exit Do
    ElseIf InStr(strText, "There is/are") Then
    arrText = Split(strText, "in total in the server")
    strVariable1 = arrText(0)
    Exit Do
    End If
    Loop








    objFile.Close

    Wscript.Echo strVariable
    Wscript.Echo strVariable1

    The issue this is having is its grabbing the right server string and echoing
    that back, then it gets the error info - but only the first instance of it.
    There are multiple instances after, which I can't get it to loop to.

    >

      My System SpecsSystem Spec

  4. #4


    Pegasus \(MVP\) Guest

    Re: VB Script that searches a file for different text, with an app


    "njmike" <njmike@xxxxxx> wrote in message
    news:A0F908A5-5F82-4581-8EFA-15BD1AF2CAA9@xxxxxx

    >
    >
    > "Pegasus (MVP)" wrote:
    >

    >>
    >> "njmike" <njmike@xxxxxx> wrote in message
    >> news:A0DC18CE-BF54-4C1E-A78F-32D7A4676F22@xxxxxx

    >> > I'm trying to do the following and not having much luck.
    >> >
    >> > I need a script that opens a text log, once opened it searches for a
    >> > unique
    >> > identifyer that resides near the top of the file and looks something
    >> > like
    >> > this:
    >> >
    >> > "running with process name
    >> > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only really
    >> > interested in the "server55" piece, but can make due with the entire
    >> > string.
    >> >
    >> > The script then needs to continue parsing the file for error conditions
    >> > which look like this:
    >> >
    >> > "There is/are 1 thread(s) in total in the server that may be hung"
    >> >
    >> > There could be multiple instances of that error message.
    >> >
    >> > What I would like to do is write to a seperate file the uniqueID, pluss
    >> > error message, something similiar to this:
    >> >
    >> > There is/are 1 thread(s) in total in the server that may be hung on
    >> > server55.
    >> >
    >> >
    >> > Any assistance would be greatly appreciated.
    >> >
    >> > Regards,
    >> >
    >> > Mike
    >> >
    >>
    >> Let's have a look at what you've got so far. We can probably built in
    >> that.
    >>
    >> Appreciate your time Pegasus, Here's what I have so far:
    >
    > Const ForReading = 1
    >
    > Set objFSo = CreateObject("Scripting.FileSystemObject")
    > Set objFile = objFSO.OpenTextFile("testIn.txt")
    >
    > Do Until objFile.AtEndOfStream
    > strText = objFile.ReadLine
    > If InStr(strText, "running with process name") Then
    > arrText = Split(strText, "and process id")
    > strVariable = arrText(0)
    > 'Exit Do
    > ElseIf InStr(strText, "There is/are") Then
    > arrText = Split(strText, "in total in the server")
    > strVariable1 = arrText(0)
    > Exit Do
    > End If
    > Loop
    >
    > objFile.Close
    >
    > Wscript.Echo strVariable
    > Wscript.Echo strVariable1
    >
    > The issue this is having is its grabbing the right server string and
    > echoing
    > that back, then it gets the error info - but only the first instance of
    > it.
    > There are multiple instances after, which I can't get it to loop to.
    >
    This looks like a pretty good start. However, your job spec is a little
    vague. Here are some questions:
    - In your initial post you mention a "UniqueID". What ID
    might this be?
    - How many server identifier lines are there? Just the one? What
    if there isn't one? What if there is more than one?
    - Do you want to write each instance of a hung process to the
    console or do you want to count them, then write a single
    summary line?
    - If you want to process the whole file, why do you have an
    "exit do" in your code?



      My System SpecsSystem Spec

  5. #5


    njmike Guest

    Re: VB Script that searches a file for different text, with an app



    "Pegasus (MVP)" wrote:

    >
    > "njmike" <njmike@xxxxxx> wrote in message
    > news:A0F908A5-5F82-4581-8EFA-15BD1AF2CAA9@xxxxxx

    > >
    > >
    > > "Pegasus (MVP)" wrote:
    > >

    > >>
    > >> "njmike" <njmike@xxxxxx> wrote in message
    > >> news:A0DC18CE-BF54-4C1E-A78F-32D7A4676F22@xxxxxx
    > >> > I'm trying to do the following and not having much luck.
    > >> >
    > >> > I need a script that opens a text log, once opened it searches for a
    > >> > unique
    > >> > identifyer that resides near the top of the file and looks something
    > >> > like
    > >> > this:
    > >> >
    > >> > "running with process name
    > >> > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only really
    > >> > interested in the "server55" piece, but can make due with the entire
    > >> > string.
    > >> >
    > >> > The script then needs to continue parsing the file for error conditions
    > >> > which look like this:
    > >> >
    > >> > "There is/are 1 thread(s) in total in the server that may be hung"
    > >> >
    > >> > There could be multiple instances of that error message.
    > >> >
    > >> > What I would like to do is write to a seperate file the uniqueID, pluss
    > >> > error message, something similiar to this:
    > >> >
    > >> > There is/are 1 thread(s) in total in the server that may be hung on
    > >> > server55.
    > >> >
    > >> >
    > >> > Any assistance would be greatly appreciated.
    > >> >
    > >> > Regards,
    > >> >
    > >> > Mike
    > >> >
    > >>
    > >> Let's have a look at what you've got so far. We can probably built in
    > >> that.
    > >>
    > >> Appreciate your time Pegasus, Here's what I have so far:
    > >
    > > Const ForReading = 1
    > >
    > > Set objFSo = CreateObject("Scripting.FileSystemObject")
    > > Set objFile = objFSO.OpenTextFile("testIn.txt")
    > >
    > > Do Until objFile.AtEndOfStream
    > > strText = objFile.ReadLine
    > > If InStr(strText, "running with process name") Then
    > > arrText = Split(strText, "and process id")
    > > strVariable = arrText(0)
    > > 'Exit Do
    > > ElseIf InStr(strText, "There is/are") Then
    > > arrText = Split(strText, "in total in the server")
    > > strVariable1 = arrText(0)
    > > Exit Do
    > > End If
    > > Loop
    > >
    > > objFile.Close
    > >
    > > Wscript.Echo strVariable
    > > Wscript.Echo strVariable1
    > >
    > > The issue this is having is its grabbing the right server string and
    > > echoing
    > > that back, then it gets the error info - but only the first instance of
    > > it.
    > > There are multiple instances after, which I can't get it to loop to.
    > >
    >
    > This looks like a pretty good start. However, your job spec is a little
    > vague. Here are some questions:
    > - In your initial post you mention a "UniqueID". What ID
    > might this be?
    > - How many server identifier lines are there? Just the one? What
    > if there isn't one? What if there is more than one?
    > - Do you want to write each instance of a hung process to the
    > console or do you want to count them, then write a single
    > summary line?
    > - If you want to process the whole file, why do you have an
    > "exit do" in your code?
    >
    >
    > Again - your time is appreciated. I'll try to clarify..
    This looks like a pretty good start. However, your job spec is a little
    vague. Here are some questions:



    Q. In your initial post you mention a "UniqueID". What ID
    might this be?
    A. I call it a unique Id, but its really a substring of the following line
    of text in the log:

    "running with process name
    USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55"
    The uniqueID, is actually the text "server55" which corresponds to a VM
    guest, running WAS - two per host, with a total of 47 hosts - so that
    uniqueID will actually be anything from server1 to server94.


    Q. How many server identifier lines are there? Just the one? What
    if there isn't one? What if there is more than one?
    A. Each log will have only one ID line in it. If there is not one, it can
    be assumed there is some sort of error condition and the text for that
    variable should read "unkonwn server" There should never be more than one,
    if there is though, they will be dupes.




    Q. Do you want to write each instance of a hung process to the
    console or do you want to count them, then write a single
    summary line?
    A.I would like to write each out to a summary file - which will be monitored
    by OVO and alert our service desk of a possible issue.



    Q. If you want to process the whole file, why do you have an
    "exit do" in your code?
    A. Good question.. Its due to inexperience with VBS.. let me try removing it.

    Regards,

    Mike


      My System SpecsSystem Spec

  6. #6


    Pegasus \(MVP\) Guest

    Re: VB Script that searches a file for different text, with an app


    "njmike" <njmike@xxxxxx> wrote in message
    news:FD9C14EF-95F1-4959-9745-D2060E56FC00@xxxxxx

    >
    >
    > "Pegasus (MVP)" wrote:
    >

    >>
    >> "njmike" <njmike@xxxxxx> wrote in message
    >> news:A0F908A5-5F82-4581-8EFA-15BD1AF2CAA9@xxxxxx

    >> >
    >> >
    >> > "Pegasus (MVP)" wrote:
    >> >
    >> >>
    >> >> "njmike" <njmike@xxxxxx> wrote in message
    >> >> news:A0DC18CE-BF54-4C1E-A78F-32D7A4676F22@xxxxxx
    >> >> > I'm trying to do the following and not having much luck.
    >> >> >
    >> >> > I need a script that opens a text log, once opened it searches for a
    >> >> > unique
    >> >> > identifyer that resides near the top of the file and looks something
    >> >> > like
    >> >> > this:
    >> >> >
    >> >> > "running with process name
    >> >> > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only
    >> >> > really
    >> >> > interested in the "server55" piece, but can make due with the entire
    >> >> > string.
    >> >> >
    >> >> > The script then needs to continue parsing the file for error
    >> >> > conditions
    >> >> > which look like this:
    >> >> >
    >> >> > "There is/are 1 thread(s) in total in the server that may be hung"
    >> >> >
    >> >> > There could be multiple instances of that error message.
    >> >> >
    >> >> > What I would like to do is write to a seperate file the uniqueID,
    >> >> > pluss
    >> >> > error message, something similiar to this:
    >> >> >
    >> >> > There is/are 1 thread(s) in total in the server that may be hung on
    >> >> > server55.
    >> >> >
    >> >> >
    >> >> > Any assistance would be greatly appreciated.
    >> >> >
    >> >> > Regards,
    >> >> >
    >> >> > Mike
    >> >> >
    >> >>
    >> >> Let's have a look at what you've got so far. We can probably built in
    >> >> that.
    >> >>
    >> >> Appreciate your time Pegasus, Here's what I have so far:
    >> >
    >> > Const ForReading = 1
    >> >
    >> > Set objFSo = CreateObject("Scripting.FileSystemObject")
    >> > Set objFile = objFSO.OpenTextFile("testIn.txt")
    >> >
    >> > Do Until objFile.AtEndOfStream
    >> > strText = objFile.ReadLine
    >> > If InStr(strText, "running with process name") Then
    >> > arrText = Split(strText, "and process id")
    >> > strVariable = arrText(0)
    >> > 'Exit Do
    >> > ElseIf InStr(strText, "There is/are") Then
    >> > arrText = Split(strText, "in total in the server")
    >> > strVariable1 = arrText(0)
    >> > Exit Do
    >> > End If
    >> > Loop
    >> >
    >> > objFile.Close
    >> >
    >> > Wscript.Echo strVariable
    >> > Wscript.Echo strVariable1
    >> >
    >> > The issue this is having is its grabbing the right server string and
    >> > echoing
    >> > that back, then it gets the error info - but only the first instance of
    >> > it.
    >> > There are multiple instances after, which I can't get it to loop to.
    >> >
    >>
    >> This looks like a pretty good start. However, your job spec is a little
    >> vague. Here are some questions:
    >> - In your initial post you mention a "UniqueID". What ID
    >> might this be?
    >> - How many server identifier lines are there? Just the one? What
    >> if there isn't one? What if there is more than one?
    >> - Do you want to write each instance of a hung process to the
    >> console or do you want to count them, then write a single
    >> summary line?
    >> - If you want to process the whole file, why do you have an
    >> "exit do" in your code?
    >>
    >>
    >> Again - your time is appreciated. I'll try to clarify..
    >
    > This looks like a pretty good start. However, your job spec is a little
    > vague. Here are some questions:
    >
    >
    >
    > Q. In your initial post you mention a "UniqueID". What ID
    > might this be?
    > A. I call it a unique Id, but its really a substring of the following line
    > of text in the log:
    >
    > "running with process name
    > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55"
    > The uniqueID, is actually the text "server55" which corresponds to a VM
    > guest, running WAS - two per host, with a total of 47 hosts - so that
    > uniqueID will actually be anything from server1 to server94.
    >
    >
    > Q. How many server identifier lines are there? Just the one? What
    > if there isn't one? What if there is more than one?
    > A. Each log will have only one ID line in it. If there is not one, it can
    > be assumed there is some sort of error condition and the text for that
    > variable should read "unkonwn server" There should never be more than
    > one,
    > if there is though, they will be dupes.
    >
    >
    >
    >
    > Q. Do you want to write each instance of a hung process to the
    > console or do you want to count them, then write a single
    > summary line?
    > A.I would like to write each out to a summary file - which will be
    > monitored
    > by OVO and alert our service desk of a possible issue.
    >
    >
    >
    > Q. If you want to process the whole file, why do you have an
    > "exit do" in your code?
    > A. Good question.. Its due to inexperience with VBS.. let me try removing
    > it.
    >
    > Regards,
    >
    > Mike
    >
    OK, this makes it much clearer. Please have a look at the code below. It's
    much the same as your own. Note that I did not test it.
    Const ForReading = 1
    ServerID = "(unknown server)"

    Set objFSo = CreateObject("Scripting.FileSystemObject")
    '***Set objFile = objFSo.OpenTextFile("testIn.txt")
    Set objFile = objFSo.OpenTextFile("c:\testIn.txt")

    Do Until objFile.AtEndOfStream
    strText = objFile.ReadLine
    'If InStr(strText, "running with process name") Then
    If InStr(strText, "running with process name") > 0 Then
    'arrText = Split(strText, "and process id")
    'strVariable = arrText(0)
    ServerID = Split(strText, "and process id")(0)
    'Exit Do (why?)
    End If
    If InStr(strText, "There is/are") Then
    'arrText = Split(strText, "in total in the server")
    'strVariable1 = arrText(0)
    WScript.Echo Split(strText, "in total in the server")(0) _
    & " on "& ServerID
    End If
    Loop

    objFile.Close

    Comments:
    Line2: Here we preset the server name, in case it's
    not defined in your text file.
    Line6: If you want your scripts to be robust then you MUST
    fully qualify each file name with drive & folder name.
    Line11: The instr function returns a number reflecting the position
    where the search string was found. If not found then it
    returns 0. Your code should reflect this.
    Line14: You can combine the two preceding lines into a
    single line of code.
    Line15: Don't exit if you want to process the whole file!
    Line20: You should write each instance of a hung process
    to the console.



      My System SpecsSystem Spec

  7. #7


    njmike Guest

    Re: VB Script that searches a file for different text, with an app



    "Pegasus (MVP)" wrote:

    >
    > "njmike" <njmike@xxxxxx> wrote in message
    > news:FD9C14EF-95F1-4959-9745-D2060E56FC00@xxxxxx

    > >
    > >
    > > "Pegasus (MVP)" wrote:
    > >

    > >>
    > >> "njmike" <njmike@xxxxxx> wrote in message
    > >> news:A0F908A5-5F82-4581-8EFA-15BD1AF2CAA9@xxxxxx
    > >> >
    > >> >
    > >> > "Pegasus (MVP)" wrote:
    > >> >
    > >> >>
    > >> >> "njmike" <njmike@xxxxxx> wrote in message
    > >> >> news:A0DC18CE-BF54-4C1E-A78F-32D7A4676F22@xxxxxx
    > >> >> > I'm trying to do the following and not having much luck.
    > >> >> >
    > >> >> > I need a script that opens a text log, once opened it searches for a
    > >> >> > unique
    > >> >> > identifyer that resides near the top of the file and looks something
    > >> >> > like
    > >> >> > this:
    > >> >> >
    > >> >> > "running with process name
    > >> >> > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55" (I'm only
    > >> >> > really
    > >> >> > interested in the "server55" piece, but can make due with the entire
    > >> >> > string.
    > >> >> >
    > >> >> > The script then needs to continue parsing the file for error
    > >> >> > conditions
    > >> >> > which look like this:
    > >> >> >
    > >> >> > "There is/are 1 thread(s) in total in the server that may be hung"
    > >> >> >
    > >> >> > There could be multiple instances of that error message.
    > >> >> >
    > >> >> > What I would like to do is write to a seperate file the uniqueID,
    > >> >> > pluss
    > >> >> > error message, something similiar to this:
    > >> >> >
    > >> >> > There is/are 1 thread(s) in total in the server that may be hung on
    > >> >> > server55.
    > >> >> >
    > >> >> >
    > >> >> > Any assistance would be greatly appreciated.
    > >> >> >
    > >> >> > Regards,
    > >> >> >
    > >> >> > Mike
    > >> >> >
    > >> >>
    > >> >> Let's have a look at what you've got so far. We can probably built in
    > >> >> that.
    > >> >>
    > >> >> Appreciate your time Pegasus, Here's what I have so far:
    > >> >
    > >> > Const ForReading = 1
    > >> >
    > >> > Set objFSo = CreateObject("Scripting.FileSystemObject")
    > >> > Set objFile = objFSO.OpenTextFile("testIn.txt")
    > >> >
    > >> > Do Until objFile.AtEndOfStream
    > >> > strText = objFile.ReadLine
    > >> > If InStr(strText, "running with process name") Then
    > >> > arrText = Split(strText, "and process id")
    > >> > strVariable = arrText(0)
    > >> > 'Exit Do
    > >> > ElseIf InStr(strText, "There is/are") Then
    > >> > arrText = Split(strText, "in total in the server")
    > >> > strVariable1 = arrText(0)
    > >> > Exit Do
    > >> > End If
    > >> > Loop
    > >> >
    > >> > objFile.Close
    > >> >
    > >> > Wscript.Echo strVariable
    > >> > Wscript.Echo strVariable1
    > >> >
    > >> > The issue this is having is its grabbing the right server string and
    > >> > echoing
    > >> > that back, then it gets the error info - but only the first instance of
    > >> > it.
    > >> > There are multiple instances after, which I can't get it to loop to.
    > >> >
    > >>
    > >> This looks like a pretty good start. However, your job spec is a little
    > >> vague. Here are some questions:
    > >> - In your initial post you mention a "UniqueID". What ID
    > >> might this be?
    > >> - How many server identifier lines are there? Just the one? What
    > >> if there isn't one? What if there is more than one?
    > >> - Do you want to write each instance of a hung process to the
    > >> console or do you want to count them, then write a single
    > >> summary line?
    > >> - If you want to process the whole file, why do you have an
    > >> "exit do" in your code?
    > >>
    > >>
    > >> Again - your time is appreciated. I'll try to clarify..
    > >
    > > This looks like a pretty good start. However, your job spec is a little
    > > vague. Here are some questions:
    > >
    > >
    > >
    > > Q. In your initial post you mention a "UniqueID". What ID
    > > might this be?
    > > A. I call it a unique Id, but its really a substring of the following line
    > > of text in the log:
    > >
    > > "running with process name
    > > USSECAVDMPAPP1Cell01\USSECAVDMPAPP28Node01\server55"
    > > The uniqueID, is actually the text "server55" which corresponds to a VM
    > > guest, running WAS - two per host, with a total of 47 hosts - so that
    > > uniqueID will actually be anything from server1 to server94.
    > >
    > >
    > > Q. How many server identifier lines are there? Just the one? What
    > > if there isn't one? What if there is more than one?
    > > A. Each log will have only one ID line in it. If there is not one, it can
    > > be assumed there is some sort of error condition and the text for that
    > > variable should read "unkonwn server" There should never be more than
    > > one,
    > > if there is though, they will be dupes.
    > >
    > >
    > >
    > >
    > > Q. Do you want to write each instance of a hung process to the
    > > console or do you want to count them, then write a single
    > > summary line?
    > > A.I would like to write each out to a summary file - which will be
    > > monitored
    > > by OVO and alert our service desk of a possible issue.
    > >
    > >
    > >
    > > Q. If you want to process the whole file, why do you have an
    > > "exit do" in your code?
    > > A. Good question.. Its due to inexperience with VBS.. let me try removing
    > > it.
    > >
    > > Regards,
    > >
    > > Mike
    > >
    >
    > OK, this makes it much clearer. Please have a look at the code below. It's
    > much the same as your own. Note that I did not test it.
    > Const ForReading = 1
    > ServerID = "(unknown server)"
    >
    > Set objFSo = CreateObject("Scripting.FileSystemObject")
    > '***Set objFile = objFSo.OpenTextFile("testIn.txt")
    > Set objFile = objFSo.OpenTextFile("c:\testIn.txt")
    >
    > Do Until objFile.AtEndOfStream
    > strText = objFile.ReadLine
    > 'If InStr(strText, "running with process name") Then
    > If InStr(strText, "running with process name") > 0 Then
    > 'arrText = Split(strText, "and process id")
    > 'strVariable = arrText(0)
    > ServerID = Split(strText, "and process id")(0)
    > 'Exit Do (why?)
    > End If
    > If InStr(strText, "There is/are") Then
    > 'arrText = Split(strText, "in total in the server")
    > 'strVariable1 = arrText(0)
    > WScript.Echo Split(strText, "in total in the server")(0) _
    > & " on "& ServerID
    > End If
    > Loop
    >
    > objFile.Close
    >
    > Comments:
    > Line2: Here we preset the server name, in case it's
    > not defined in your text file.
    > Line6: If you want your scripts to be robust then you MUST
    > fully qualify each file name with drive & folder name.
    > Line11: The instr function returns a number reflecting the position
    > where the search string was found. If not found then it
    > returns 0. Your code should reflect this.
    > Line14: You can combine the two preceding lines into a
    > single line of code.
    > Line15: Don't exit if you want to process the whole file!
    > Line20: You should write each instance of a hung process
    > to the console.
    >
    >
    > Pegasus,
    It worked perfectly. Going to do some testing on it.
    Regards,
    Mike


      My System SpecsSystem Spec

  8. #8


    Pegasus \(MVP\) Guest

    Re: VB Script that searches a file for different text, with an app


    "njmike" <njmike@xxxxxx> wrote in message
    news:168120DC-E2B0-4951-83AA-8E8E6C03C47E@xxxxxx

    >
    > Pegasus,
    > It worked perfectly. Going to do some testing on it.
    > Regards,
    > Mike
    >
    Thanks for the feedback.



      My System SpecsSystem Spec

VB Script that searches a file for different text, with an append. problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Append text to top of text file? Get-James PowerShell 20 23 Feb 2009
Need help with log ( text ) file - write vs append Tcs VB Script 2 08 Feb 2009
exporting results/text of powershell script to a file as it is run markm75 PowerShell 2 03 Sep 2008
Having all Export files append to 1 file, xls, or csv... j0seg PowerShell 6 11 Feb 2008
output .ps1 script to text file Aaron PowerShell 2 11 Jul 2007