Page 1 of 1 1
Topic Options
#171781 - 2006-12-20 10:55 AM ReadLine issue - tasklist-wrapper SOLVED
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
I'm toying around with a script, that will use tasklist, and/or taskkill / start a task. But, encountered a problem I have no idea how to solve.
I think the issue is within my creation of the temporary-file. Please look for yourself and any hints, tips etc are as always welcome. sidenote: running with 4.53.
Code:
If NOT @LOGONMODE
	Break On
EndIf

Dim $SO,$command,$procserv
$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")

$command = 'tasklist'
$procserv = 'winamp'

dim $Rnd,$TempPath,$TempFile,$Handle,$ReadLine

SRND(@MSECS)
$Rnd = RND
$TempPath = ExpandEnvironmentVars('%temp%')
$Handle = FreeFileHandle()

if instr(right($TempPath,1),'\') 
  $TempFile = $TempPath + $Rnd + '.txt' 
 else 
  $TempFile = $TempPath +'\'+ $Rnd + '.txt' 
endif

shell 'cmd.exe /C ' + $command + ' > ' + $TempFile 

	if Open($Handle,$TempFile)  = 0
     $ReadLine = ReadLine($Handle)
    	while @ERROR = 0
    	if instr($ReadLine,$procserv) 'Found '+ $ReadLine ' ? endif
      	 $ReadLine = ReadLine($Handle)
    loop 
	close($Handle)
	endif


Edit: forgot to mention - the issue is within the ReadLine, that just starts an infinite loop *_*, thus, readline never really reaches the file/ end of file.


Edited by Björn (2006-12-20 01:53 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#171786 - 2006-12-20 11:44 AM Re: ReadLine issue - tasklist-wrapper [Re: Björn]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
replace
if instr($ReadLine,$procserv) 'Found '+ $ReadLine ' ? endif

by
if instr($ReadLine,$procserv) 'Found '+ $ReadLine ? endif

there is one extra quote
_________________________
Christophe

Top
#171790 - 2006-12-20 12:25 PM Re: ReadLine issue - tasklist-wrapper [Re: ChristopheM]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
wow... Do I feel stupid or what *_* I Owe you one Christophe!
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#171792 - 2006-12-20 02:05 PM Re: ReadLine issue - tasklist-wrapper [Re: Björn]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Look at the Sanity() udf / script, or download KGen from my web site, which has Sanity built-in. It will find and report these missing quote / mismatched quote, and missing/mismatched paren issues, as well as generate a report of variable usage by UDF.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171793 - 2006-12-20 02:08 PM Re: ReadLine issue - tasklist-wrapper [Re: Glenn Barnas]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Thanks Glenn! Been thinking alot about the sanity udf, and yes, it is a must download for me ... \:\)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.036 seconds in which 0.016 seconds were spent on a total of 13 queries. Zlib compression enabled.

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