Page 2 of 2 <12
Topic Options
#13225 - 2002-12-02 07:56 PM Re: Count lines in a file
LilmanHSU Offline
Fresh Scripter

Registered: 2002-11-27
Posts: 6
Loc: Calabasas, CA
Hey guys,

the stuff you've given me to work with right now is great.

One problem.

My count script uses the IF then statements to determine if its over or less than 10

It then shells to a BLAT command to attach the result.txt file to an email.

The problem is since the script is still running, it makes the file read only and can't be accessed.

I was thinking about moving the count script and if/then script it to its own file and just shell out the running of each one from a "main" file, but if I do that, won't I lose the $count variable and it won't know how many sites are down?

Ya know what I mean? Here is my script:

shell "dir.bat" (This makes the dir.txt file, I can't seem to get it to work within the kixstart script, it doesn't do anything)
$count = 0
$FileName = "C:\branches\dir.txt"
$ResultFile = "C:\branches\Result.txt"
IF Open(1, $FileName) = 0
$x = ReadLine(1)
WHILE @ERROR = 0
$count = $count + 1
$x = ReadLine(1)
LOOP
ENDIF
IF Open(2, $ResultFile,5) = 0
$x = WriteLine( 2 , "Log " + $FileName + " reports " + $count + " down sites" + Chr(13) + Chr(10) )
ELSE
BEEP
? "failed to open file, error code : [" + @ERROR + "]"
ENDIF
if $count < 10
shell "lessthan.bat"
else
shell "greaterthan.bat"
endif

Top
#13226 - 2002-12-02 08:01 PM Re: Count lines in a file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
2 quickies:
- please do go and modify your post to have the script in code-tags.
- what is in the dir.txt?
_________________________
!

download KiXnet

Top
Page 2 of 2 <12


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.056 seconds in which 0.031 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