Page 1 of 1 1
Topic Options
#198594 - 2010-05-12 08:53 PM Continuously Writing into a txt file and stop after past some minutes
Adolfo Offline
Fresh Scripter
*****

Registered: 2007-01-25
Posts: 49
Loc: Cali, CO
Hi,

Please your help with the following:

I am capturing some information from a continuously reading and I am writing it into a Txt file.

Code:
 Quote:

SHELL '%COMSPEC% /c \\path\WinDump.exe -i 2 -q -t | find /i "length" > c:\text.txt'


How can I do for stop that capturing after past 1 minute using CTRL+C (not sendkeys) or using another way?

Thanks.

Top
#198595 - 2010-05-13 08:36 AM Re: Continuously Writing into a txt file and stop after past some minutes [Re: Adolfo]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
It's not too tricky.

First, use RUN so that the process detaches from the script and runs in a seperate thread.

Now wait a bit and then kill the process using one of the "proc" UDFs.

Here is an untested example, you will need the EnumProcess() UDF.

 Code:
$sProcess="WinDump.exe"

; Start the windump process, use Run to allow script to continue
Run '"'+%COMSPEC%+'" /c \\path\'+$sProcess+' -i 2 -q -t | find /i "length" > c:\text.txt' 

; Wait 5 miniutes...
Sleep 300

; We've done enough, so kill process
$=EnumProcess($sProcess,"true")

Exit 0

Top
#198596 - 2010-05-13 11:29 AM Re: Continuously Writing into a txt file and stop after past some minutes [Re: Richard H.]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If you are capturing network traffic then switch to the current version of Wireshark .

This has command line tools such as tshark which will allow you to specify things like capture period, file size, file rotation and a whole host of other useful parameters

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

Generated in 0.055 seconds in which 0.028 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