My objective is to parse a file (“mf printer.edp”), search for a specific line of text (“ResourceName=”) and return that string of text. I’ve read through most of the posts and tried massaging similar scripts but can’t get it right to obtain the desired result. I’m thinking my approach is too simplistic. This is a sample of what I’ve tried so far and many iterations (of it) since:
Q: (exists file “C:\temp\mf printer.epp”) of it ((whose line contains “ResourceName=”) as text))
If any line of the file contains “ResourceName=”, then it will report true. You may want to consider “starts with” instead of “contains” if you are looking for this string at the start of a line. And if the file is case insensitive, then you should use:
Q: exists file “C:\test.txt” whose (exists (line of it) whose (it as lowercase starts with “resourcename=”))
hi there, I need to search a text file just like in the example above. Although this works fine, I’d prefer not to hard code the folder path … so pls can you advise me whats wrong with the following:-
(not exists file “sometext.log” of folder (pathname of parent folder of regapp “besclient.exe”) whose (exists (line of it) whose (it contains “sucessful”)
You just need to move your whose clauses around a bit:
not exists file “sometext.log” whose (exists line whose (it contains “successful”) of it) of folder (pathname of parent folder of regapp “besclient.exe”)
Is it possible to return ‘part of’ a line of text in a file ?
i.e.
if exists file (“C:\Program Files\Symantec\ESM\Bin\w3s-ix86\3sysver.log”) then following texts of firsts “3sysmod” of lines whose (it contains “3sysmod”) of file (“C:\Program Files\Symantec\ESM\Bin\w3s-ix86\3sysver.log”) else “n/a”
preceding text of position 2 of (if exists file (“C:\test\num.txt”) then following texts of firsts “JUNK” of lines whose (it contains “JUNK”) of file (“C:\test\num.txt”) else “n/a”)
this would display JU out of JUNK
so just modify it for a 5 and encapsulate your relevance.
Sonny’s relevance will work fine… but you can also rewrite it as:
first 6 of
which would be something like:
if exists file (“C:\Program Files\Symantec\ESM\Bin\w3s-ix86\3sysver.log”) then first 6 of following texts of firsts “3sysmod” of lines whose (it contains “3sysmod”) of file (“C:\Program Files\Symantec\ESM\Bin\w3s-ix86\3sysver.log”) else “n/a”
I can think of 2 ways right off the bat… chose the line with the highest line number, or parse out the time stamps and choose the maximum. The relevance for the time stamp version will be a little more straightforward. If you post an example line I can give you an exact relevance query, but in pseudo code it would look like this:
maximum of ({relevance to extract time stamp string} as time) of lines whose (it contains “Update Finsihed”)…
Some good tips in this post but I need something just a bit different.
I need to search a file to check two things.
that it has a specific string in it
and whether or not that line with the string in it starts with a # or not.
I need to check whether or not this particular item is commented out and unfortunately since the entire line string is not consistant, I cant check for an exact match with the # in front, so I’m stuck trying to make this like a wildcard lookup.
Some thing like lines starting with “#” and contains “”
Guys… i’m trying to recurse a text file that contains lines of absolute paths… I just want to run it in a loop and return the file sizes of them… Any input?
this code DOES NOT work:
(size of file (lines of file “c:\program files\bigfix enterprise\bes client\searchresults_pst.txt”)) as string & " KB"
I suck… help… too much vb recently, i’m forgetting my bigfix coding skills!