Page 1 of 1 1
Topic Options
#42647 - 2003-07-09 02:34 PM Using ReadFile output
The_Apprentice Offline
Fresh Scripter

Registered: 2003-05-30
Posts: 16
Loc: Guildford, England
Afternoon,

Just a quick question. aren't they all [Razz]

I ammusing the ReadFile function, and try to capture some of the text.
Extract of code is....

$file = 'C:\Program Files\Sophos Sweep for NT\NTInst\i386\sav.cfg'
for each $line in ReadFile($file,,-1)
$line ? ; confirms this bit is working
next
if @error "error @error" endif
$vsoph = RIGHT($line,2)
$vsoph ?

The ReadFile returns the line I want.
eg: SerialNumber=43
I then want to capture the last two characters (43), but am not getting anything back.
I think the code is right.

Any ideas please.

Many thanks in advance

Top
#42648 - 2003-07-09 02:43 PM Re: Using ReadFile output
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, you could use your loop and make the change in there.
but if you only want that one line this should be more efficient:
code:
$lastLine=ReadFile('C:\Program Files\Sophos Sweep for NT\NTInst\i386\sav.cfg',,-1)
$lastLine[0] ?
right($lastLine[0],2)

if you are reading just one line, you might consider using delim and then remove that from output...
many ways.

if I would code this usage for myself, I would just make it like:
code:
;output last 2 chars from last line of file to the console:
right(ReadFile('C:\Program Files\Sophos Sweep for NT\NTInst\i386\sav.cfg',,-1)[0],2)

but that might be too cool [Razz] [Big Grin]
_________________________
!

download KiXnet

Top
#42649 - 2003-07-09 02:52 PM Re: Using ReadFile output
The_Apprentice Offline
Fresh Scripter

Registered: 2003-05-30
Posts: 16
Loc: Guildford, England
Many thanks.

I can now use the output to check against a registry entry on the clients to confirm all is up to date.

[Smile]

Top
#42650 - 2003-07-09 02:58 PM Re: Using ReadFile output
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
now now...
I must wonder why you don't check it directly from registry?
_________________________
!

download KiXnet

Top
#42651 - 2003-07-09 04:25 PM Re: Using ReadFile output
The_Apprentice Offline
Fresh Scripter

Registered: 2003-05-30
Posts: 16
Loc: Guildford, England
Ahhhhhhhhhhhhh.
When sophos downloads the new IDE files, it updates the sav.cfg in the NTInst folder with the new version, it is just an incremented number.

When the clients do a scheduled update from the "distribution" server the value in sav.cfg is written to the registry of the client.

So, if you compare the two values you know the status.

The main reason we have to do this, is 'cos of security on the network I am monitoring, SAVADMIN can not see the clients [Embarrassed]

.

Top
#42652 - 2003-07-09 07:14 PM Re: Using ReadFile output
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, that makes sense.
anyway, glad that you got it working.

just tell us if we can help with something else.

cheers
_________________________
!

download KiXnet

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.188 seconds in which 0.128 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