Today
Wed Feb 23 00:22:28 CST 2005
Al Dunbar [MS-MVP] wrote:
> "Today" <ex> wrote in message news:WtGdnWRUKfulmYffRVn-1w@adelphia.com...
>
>>Thanks for the reply Al, I need it to execute another file
>
>
> What is the nature of this other file that you need to execute? Could it be
> modified to determine whether or not it should do whatever it is to do with
> the file, and simply terminate itself without doing anything in the event
> that that is what is desired?
>
>
>> 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.
>
>
> The sample code I provided should work regardless how much text appears
> between the two statements - did you not try it?
>
>
>>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.
>
>
> I expect your cutting and pasting introduced a problem there. Did you
> attempt my approach at all?
>
>
>>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:
>
>
> Nice sample, but it does not contain any instances of the statements you
> originally said you needed to look for. What are the equivalent strings (or
> commands) that you want to find in the sample below?
>
>
>>- <ScanResults>
>> <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.msp
> x</BulletinUrl>
>
>>
>>
> <DownloadURL>
http://download.microsoft.com/download/E/1/4/E14C0C02-591B-4696
> -8552-EB710C26A3CD/NDP1.1sp1-KB886903-X86.exe</DownloadURL>
>
>> <PatchName />
>> <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.msp
> x</BulletinUrl>
>
>>
>>
> <DownloadURL>
http://download.microsoft.com/download/c/8/5/c851bf78-0907-4fc7
> -ae1b-1b9c4fb1474d/WindowsMessenger-KB887472-PreXPSP2-ENU.exe</DownloadURL>
>
>> <PatchName />
>> <Description />
>> <Status>Installed</Status>
>> <ItemType />
>> <DatePosted />
>> <DateRevised />
>> <UnattendSyntax>/q /norestart</UnattendSyntax>
>> </Item>
>> </Product>
>> </Machine>
>> <Comments />
>> </ScanResults>
>>
>>As you can see the <status> is listed after the bulleting ID and Product
>>name.
>
>
> As you say. But this seems to me a different problem entirely from what you
> originally posted. Are you wanting to look for one particular command then
> see if something precedes it, execute the other file, and then go and look
> for something else? And if you find some string and then some other string
> before it, can you be sure at all that they were both contained within the
> same "<product>"?
>
> Seems to me that you need significantly more than a simple text search,
> namely an XML-aware parser, as I and others have suggested to you.
>
>
> /Al
>
>
>>
>>
>>Al Dunbar [MS-MVP] wrote:
>>
>>>"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
>>>
>>>
>>>
>
>
>
Thanks Al, I will try to learn how to use MSFT's XML parser to
accomplish this.
Regards.