Ayush
Wed Dec 13 05:39:49 CST 2006
Replied to [Ahmed H. Habashy]s message :
-----------------------------------------------------------
> Here is a sample of the log File Generated by the application and i need to
> choose some fields to be copied or appended to my Report .txt file which is
> generated by a VB Script.
[[[snippedddd]]]]
I am new to VBScript but i made this JScript. No difference, you can use this by
pasting this in Notepad and saving as .hta extension. :
--------Dont-Include-This-Line------------------------
<script>
onerror=cerr
function cerr(a,b,c){
alert('Error occured !! Script will now close.');
window.close();
return true
}
//Dont Edit above this line
Append="Process Name,Process Id,State"
FilePath="E:\\Tempp\\Report.txt";
//Dont edit below this line
Append=Append.split(',');
oSF=new ActiveXObject("Scripting.FilesystemObject")
ReadF=oSF.OpenTextFile("E:\\Tempp\\aaa.xx",1)
Arr = ReadF.ReadAll();
ReadF.Close()
Arr=Arr.toString().split('\n')
Arr2=new Array();
for(x=0;x<Arr.length;x++){
sep=Arr[x].indexOf(':');
Arr2[x]=Arr[x].substring(sep+1,Arr[x].length);
Arr[x]=Arr[x].substring(0,sep);
}
lineNs=''
for(xx=0;xx<Append.length;xx++){
for(xxx=0;xxx<Arr.length;xxx++){
if(Arr[xxx].indexOf(Append[xx])!='-1'){
lineNs+=Arr[xxx]+':'+Arr2[xxx]+'\n';
}}}
if(oSF.FileExists(FilePath)!=true){
alert('File "'+FilePath+'" does not exist...Script will now close.')
window.close()
}
appendTF=oSF.GetFile(FilePath);
openF=appendTF.OpenAsTextStream(8)
openF.Write('\n'+lineNs)
openF.Close()
window.close()
</script>
--------Dont-Include-This-Line------------------------
It will do the same....
You have to change two things:
1. The value of the first Append that is now :
"Process Name,State"
Dont remove quotes. SPecify the values you want to copy by a comma (,) like in this
example the script will append the line Process Name and State line. If you want to
copy the values only(svchost.exe etc.), tell me.
2. Change the value of FilePath that is :
FilePath="E:\\Tempp\\Report.txt"
to
FilePath="TheReportFilePath"
Note that two backslahes is are equal to one backslash in JScript so this will be
wrong :::
FilePath="E:\Tempp\Report.txt"
Ayush [ Good :-) Luck ]
-------------
Search - www.Google.com | Wikipedia -
http://en.wikipedia.org
Snip your long urls -
http://snipurl.com/
-------------