Page 1 of 1 1
Topic Options
#131691 - 2004-12-21 05:03 PM File split
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
I need to read a file similar to the one below into an array and then create seperate files based on the computername entries in the file. I believe that I'd need to look for this string "----------------------------", but since there are two of those lines for each computer entry, I'm not sure how to split it out. Any advice would be appreciated.

Code:
  
Scan performed Tue Dec 21 09:43:55 2004
Shavlik Technologies Network Security Hotfix Checker, 3.86
Using XML data version = 1.1.2.304 Last modified on 12/15/2004.


----------------------------
COMPUTER1 (190.25.245.245)
----------------------------

* WINDOWS XP SP2

Information
All baseline security hotfixes have been applied.


* INTERNET INFORMATION SERVICES 5.1 SP2

Information
All baseline security hotfixes have been applied.


----------------------------
COMPUTER2 (190.25.245.246)
----------------------------

* WINDOWS XP SP1

Warning
The latest service pack for this product is not installed.
Currently SP1 is installed. The latest service pack is SP2.

Information
The latest Service Pack for this application has not been

installed.
Please install the latest service pack before evaluating this

system
against baseline security standards.


----------------------------
COMPUTER3 (190.25.7.124)
----------------------------

* WINDOWS 2000 SP4

Information
All baseline security hotfixes have been applied.


* INTERNET INFORMATION SERVICES 5.0 SP4

Information
All baseline security hotfixes have been applied.

_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#131692 - 2004-12-21 05:23 PM Re: File split
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
That should be a trivial task. Read the file into an array with the ReadFile() UDF and then just iterate through the array. From the example you give, the line before the first of two elements containing "----------------------------" ends with a "." and the line before the second element (but after the first, the one you want) ends with a ")".

Edited by Les (2004-12-21 05:26 PM)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#131693 - 2004-12-21 09:00 PM Re: File split
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Brewdude,
I see you stopped back in but did not say hello. Have I not given you enough to get you started?

Here is a little proof of concept to start you on your way.
Code:
break on


$filearray = ReadFile('C:\KiXscripts\test.dat')

For $element = 2 to UBound($filearray)
if right($filearray[$element-2],1) = '.'
if $filearray[$element-1] = '----------------------------'
if right($filearray[$element],1) = ')'
$filearray[$element-2] ?
$filearray[$element-1] ?
$filearray[$element] ?
endif
endif
endif
next



Edited by Les (2004-12-21 09:10 PM)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#131694 - 2004-12-22 12:32 AM Re: File split
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Actually, what I've decided to do instead is load the list of computernames I want to scan into an array and run hfnetchk for each computername. Thanks for the example.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1376 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.034 seconds in which 0.018 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org