Re: Reading Reults of txt file - and then...
From: Today (ex)
Date: 02/21/05
- Next message: Steve Seguis [MVP]: "Re: Adding regkey"
- Previous message: Franck: "How can I log my vbscript command"
- In reply to: Al Dunbar [MS-MVP]: "Re: Reading Reults of txt file - and then..."
- Next in thread: Al Dunbar [MS-MVP]: "Re: Reading Reults of txt file - and then..."
- Reply: Al Dunbar [MS-MVP]: "Re: Reading Reults of txt file - and then..."
- Reply: Roland Hall: "Re: Reading Reults of txt file - and then..."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 21 Feb 2005 07:54:30 -0800
Thanks for the reply Al, I need it to execute another file if it finds
that the first line exists and then the second line tells me what it is
that I need to execute, well not exactly, but I can evaluate it to get
the right info to launch what I need. The problem, as I see it, is that
the length between the two statements will not be the same, and the XML
file does not appear to have any CR's in Notepad.
On the MSFT script center I found a script to take a txt file and run it
backwards, which would work, but when I put it in my vbs it just seemed
to launch an endless loop, CPU went to 100% and I had to kill the process.
The file I am reading is the Results.xml file from the MSFT FEB EST. I
have a few hundred people who are still not part of SMS and several
regional offices that need to be patches for 004, 006, 009 and I do this
in a vbs every month.
Here is an example of the output:
- <ScanResults>
<PatchName />
<PatchName />
As you can see the <status> is listed after the bulleting ID and Product
Al Dunbar [MS-MVP] wrote:
<ScanDateTime>2/20/2005 11:31:21 AM</ScanDateTime>
<XMLDataVersion>2005.2.20.0</XMLDataVersion>
<ScannedBy>ANCHOR \ SYSTEM</ScannedBy>
- <Machine>
<MachineName>ANCHOR</MachineName>
<Domain>AVWORLD</Domain>
- <Product>
<ProductName>.NET FRAMEWORK 1.1 SP1</ProductName>
- <Item>
<LocaleID>1033</LocaleID>
<ItemClass>Patch</ItemClass>
<BulletinID>MS05-004</BulletinID>
<BulletinTitle>Vulnerability in ASP.Net May Lead to Authentication
Bypass</BulletinTitle>
<SQNumber>886903</SQNumber>
<BulletinUrl>http://www.microsoft.com/technet/security/bulletin/MS05-004.mspx>
<DownloadURL>http://download.microsoft.com/download/E/1/4/E14C0C02-591B-4696-8552-EB710C26A3CD/NDP1.1sp1-KB886903-X86.exe>
<Description />
<Status>Installed</Status>
<ItemType />
<DatePosted />
<DateRevised />
<UnattendSyntax>/q</UnattendSyntax>
</Item>
</Product>
- <Product>
<ProductName>WINDOWS MESSENGER 4.7.0.2009</ProductName>
- <Item>
<LocaleID>1033</LocaleID>
<ItemClass>Patch</ItemClass>
<BulletinID>MS05-009</BulletinID>
<BulletinTitle>Vulnerability in PNG Processing Could Lead to Buffer
Overrun</BulletinTitle>
<SQNumber>887472</SQNumber>
<BulletinUrl>http://www.microsoft.com/technet/security/bulletin/MS05-009.mspx>
<DownloadURL>http://download.microsoft.com/download/c/8/5/c851bf78-0907-4fc7-ae1b-1b9c4fb1474d/WindowsMessenger-KB887472-PreXPSP2-ENU.exe>
<Description />
<Status>Installed</Status>
<ItemType />
<DatePosted />
<DateRevised />
<UnattendSyntax>/q /norestart</UnattendSyntax>
</Item>
</Product>
</Machine>
<Comments />
</ScanResults>
name.
> "Today" <ex> wrote in message news:eMidndtAa_y0aYXfRVn-pQ@adelphia.com...
>
>>I am using FSO to read a XML file, using the ReadAll method. I have a
>>couple of questions. First how does an XML file appear to wsh?
>
>
> What WSH sees of it through the File System Object is a text file.
>
>
>> Is it
>>one silgle line like in Notepad or is there several lines like when
>>displayed in IE?
>
>
> Notepad will likely do a better job of showing you how the XML file is
> actually formatted with newline characters and other whitespace.
>
>
>> If it is seperate lines I can use the readline to get
>>what I need,
>
>
> What is it that you actually need?
>
>
>> if it is diplayed with no CR's then I don't think that
>>method will work. I am using ReadAll and I can find the data I want but
>>then if the data is found I need to then read data before it, as an
>
> example:
>
>><services>test</services>
>>
>>Is what I am looking for first, and if this text exists I then need to
>>go backwards and look for
>>
>><process>ten</process>.
>>
>>The data length between these two can vary for each instance within the
>>file, where some other data may be <asdf>fkjshdfkjhksjdfh</asdf> for one
>>instance, and for another it may be <asd>adf</asd>.
>
>
> Once you have found these tags (or not, depending on whether or not they are
> present), what will your script do - just report its success? Or will you
> then need to perform some other XML-type manipulations of some sort?
>
> Assuming that you just need to determine whether or not the services tag
> exists and is preceded by the process tag, and assuming that these tags will
> be EXACTLY as you have shown them in the XML data stream, I would tend to
> use readall, with logic along these lines:
>
> services = "<services>test</services>"
> process = "<process>ten</process>"
> xms = whatever.readall
> findservices = instr( 1, xms, services, vbtextcompare )
> if ( findservices = 0 ) then
> wscript.echo "did not find " & services
> else
> findprocess = instr( 1, xms, process, vbtextcompare )
> if ( findprocess = 0 ) then
> wscript.echo "found " & services & " but not " & process
> elseif ( findprocess > findservices ) then
> wscript.echo services & " NOT preceded by " & process
> else
> wscript.echo services & " IS preceded by " & process
> end if
> end if
>
>
> If you need to perform XML-compliant operations on an XML file, I would
> recommend that you use an XML-specific object instead of FSO.
>
>
> /Al
>
>
>
Relevant Pages
|