I'm working to have a script that will analyze a value present into a log file.
All my log lines are the same and the must updated information is located in the very first line of the file.
So, basically I need read the very fist line of my log file.
But... I'm facing a issue.
I have my script working and i'm getting the first line..... for some files...
Here is the script
@codepage(1252) benchmark WebBenchmarkName use"WebAPI.bdh" use"Kernel.bdh" dcluser user WebUser transactions TMain : 1; dcltrans transaction TMain var hFile, nRead, nSize, nPos1, cpt, nPos: number; sData, sLine : string; sFile : string; bFileExists : boolean; begin sFile:="\\\\dalapp65\\sms_logs\\Connlogprd.log"; bFileExists := FExists(sFile); if bFileExists then FOpen(hFile, sFile, OPT_FILE_ACCESS_READ, OPT_FILE_OPEN, OPT_FILE_SHARE_READ); // calculate and display the number of bytes in the file FSizeGet(hFile, nSize); print("file size = "+string(nSize)); // read nSize number of bytes into sData FRead(hFile, sData, nSize, nRead); print(string(nRead)+" bytes read"); print(sFile); print(sData); else Print("No Tests to be executed."); sData:=" "; end; nPos1 := StrSearch(sData, "\r", STR_SEARCH_FIRST); print("line1: " + substr(sData,sLine,1,nPos1)); FClose(hFile); end TMain;
When I run this I got the following information on the Output screen on Workbench server: ( see Output1 file attached)
But when I run this trying to read the file that I need I got the following information on the output screen (see output2 file attached).
There is no error messages, no warnings... the only that don't happen is read the file that I need.
Both files are located in the same directory which clear out the level of access to the files..I'm able to open the file that I need using Notepad++ or Notepad and I don't get any errors.
Could someone have any hint about it?
Message was edited by: Flavio Bonacordi The copy/paste of the code wasn't correct... this is the right version