PDA

View Full Version : Replacing a line of text from a text file (All)



codeexploiter
03-23-2006, 01:36 AM
Hi All,

How can we replace a line (based on some condition) from a constantly changing text file using VBScript. In other words a text file is being used to store some data by an application that runs all the time, I want to create another script using VBScript using I want to read the changing text file and replace some lines based on some of my conditions.

Please share your thoughts in this issue.

Regards

Code Exploiter

<P ID="edit"><FONT class="small">Edited by codeexploiter on 03/23/06 01:37.</FONT></P>

motoflop
03-23-2006, 04:55 AM
If there is another application constantly writing to that file, you cannot replace any text on that file until that other applications stops. Only one program can have a file opened for writing simultaneously. You can read that file (unless that applications has prevented it) and write copy of it with any required changes to another file. So you need simple script, which read a file and writes another file.

codeexploiter
04-03-2006, 11:01 PM
Thanks motoflop, though my purpose won't be going to be done successfully. Have to find some other strategy

Regards
Code Exploiter

cprasley
04-29-2006, 10:00 PM
Is there any way you can divert the output of the program, either by forcing it to write to the standard output or to a named pipe? If so then you could have it pipe the data to your script and then the script could do the filtering and write to a physical file.