0
votes

I have text file with multiple line of different jobs jobs status .last run date..etc has been given as below

Jobname=FC;lastdate=12032015;lastresult=0

I need to write out the jobname and lastresult status with "success" for 0 and "fail" for other cases.

2
Are you looking for someone to write the vbscript for you, or did you have a particulate question about the script you've written? - JNevill
I don't hv script handy..I just not able to find command to match the pattern...I don't need to write script for me...but can give me a clue to do that.. - Vimal2311

2 Answers

0
votes

As you iterating through the lines of the file (where readline is the variable holding the line we are reading at the time):

jobname= Split(Split(readLine, ";")(0), "=")(1)
if Split(Split(readLine, ";")(2), "=")(1) = 0 Then
    lastresult="Success"
else
    lastresult="Failure"
end if

Something like this should capture your jobname and lastresult. We are just using SPLIT() to split the string by a delimiter ";" and grabbing the token we need (and then splitting that as well).

0
votes

Use a Regexp looking for = followed by a sequence of non-; and an array indexed by the comparison between "=0" and the last part of the input line - as in:

>> Set r = New RegExp
>> r.Global = True
>> r.Pattern = "=[^;]+"
>> a = Split("success fail")
>> s = "Jobname=FC;lastdate=12032015;lastresult=0|Jobname=Other;lastdate=12032015;lastresult=Else"
>> For Each s In Split(s, "|")
>>     Set ms = r.Execute(s)
>>     WScript.Echo Mid(ms(0).Value,2), a(1 + ("=0" = ms(2)))
>> Next
>>
FC success
Other fail