ddady
(Getting the hang of it)
2007-09-18 09:07 AM
Problem with ReadFileTail Function

Good Morning to ALL.

I have used the ReadFileTail function and it works great. My problem starts when i'm trying to use the script on my DC.
I have tried the script on my local machine and everything works well then i copied the script to the DC and made the relevant changes and it doesn't read the lines in the file. It seems that there is problem reading from this particular file since it works on a different file. The file i wanr to read from is a regular log file with the archive attribute.

here are the relevan code lines:

 Code:
$text = ReadFileTail ("N:\RetalixLogs\datam.log", 10)
WriteFile ("N:\RetalixLogs\DataCheck.txt", $text)
PrintTo2 ("N:\RetalixLogs\DataCheck.txt","\\dc\OkiSvn")


I'm trying to read the 10 last lines from the 'datam.log' file and to write them into the 'DataCheck.txt' file and to print it.
As i mentioned at the begining with defferent files it works great, any suggestions will be appriciated.


Mart
(KiX Supporter)
2007-09-18 09:12 AM
Re: Problem with ReadFileTail Function

Ddady,

Only UDF's should be in the forum. If you have any questions about a UDF please make a post is basic or advanced scripting. If you put a link in the post to the UDF we all know what UDF your are using.


Can a mod please move this thread to basic or advanced scripting?


JochenAdministrator
(KiX Supporter)
2007-09-18 09:21 AM
Re: Problem with ReadFileTail Function

ddady,

you might try to catch an error after readfiletail:

 Code:
$text = ReadFileTail ("N:\RetalixLogs\datam.log", 10)
if @error
    "Error " + @error + " [" + @serror + "] occurred"
    get $
    exit 1
endif
WriteFile ("N:\RetalixLogs\DataCheck.txt", $text)
PrintTo2 ("N:\RetalixLogs\DataCheck.txt","\\dc\OkiSvn")


ddady
(Getting the hang of it)
2007-09-18 10:35 AM
Re: Problem with ReadFileTail Function

Mart, sorry i didn't know, wont happen again.

Jochen, i will try it and will post the results.


ddady
(Getting the hang of it)
2007-09-18 10:47 AM
Re: Problem with ReadFileTail Function

That's is the error i'm getting

"urred 24 [The program issued a command but the command length is incorrect.] occ"


Mart
(KiX Supporter)
2007-09-18 10:51 AM
Re: Problem with ReadFileTail Function

 Originally Posted By: ddady
Mart, sorry i didn't know, wont happen again.
....


No worries. It has been moved already so all is ok.


JochenAdministrator
(KiX Supporter)
2007-09-18 11:14 AM
Re: Problem with ReadFileTail Function

Hmmm ... odd error, never had this before.

To make sure it isn't caused by the udf, run this and post your results:

 Code:
break on

$_ = setoption("WrapAtEOL","ON")
$_ = open(1,"N:\RetalixLogs\datam.log")

if not @error
    $_ = readline(1)
    while not @error
        $_ ?
        $_ = readline(1)
    loop
    $_ = close(1)
else
    "" + @error + " [" + @serror + "]"
endif

get $_
exit 1


ddady
(Getting the hang of it)
2007-09-18 01:29 PM
Re: Problem with ReadFileTail Function

Ok, It opens the content of the 'datam.log' file in a command window.

Could it be that this function can't handle a file with 796 lines?

I'm just guessing here since it workd perfect on a file with 50 lines.

The instructions on this function says that there is no limit or if i missunderstood 1000 lines. But still i need only 10 lines which is the default.

ReadFileTail()


Mart
(KiX Supporter)
2007-09-18 01:44 PM
Re: Problem with ReadFileTail Function

Maybe a stupid question but did you also include the PadStr UDF?
The ReadFileTail UDF is dependant of that UDF.

 Quote:

....
DEPENDENCIES Function PadStr()
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?
ubb=get_topic;f=12;t=000223#000000
....


PadStr() - Left or Right pad a string


ddady
(Getting the hang of it)
2007-09-18 03:05 PM
Re: Problem with ReadFileTail Function

Ok, i think i found out something interesting.

The original file i'm trying to read from is with 796 lines. I have deleted line from there until i reached 500 lines and WALLA, it works!

SO i guess the function cant handle more than that which is very strange [and here is the knockout] i have created a whole different file and put into it 793 lines and it worked so i realy frustrated.

Any Ideas ????????


JochenAdministrator
(KiX Supporter)
2007-09-18 03:39 PM
Re: Problem with ReadFileTail Function

Hmm ... maybe a character in the file that causes readline to choke on (It is designed to read ASCII files only)

ddady
(Getting the hang of it)
2007-09-18 04:26 PM
Re: Problem with ReadFileTail Function

I didn't see any special characters. Anyway i manage to work around it with the ReadFile() Function

The printing of the lines is not nice as it comes out from the other function but it works. If there is a way to arrange the 5 lines that way they would come out in separate lines insted of all 5 lines in one line i will be more than glad to hear about it.


JochenAdministrator
(KiX Supporter)
2007-09-18 04:29 PM
Re: Problem with ReadFileTail Function

Show some code and one of us will place some @crlf macros in it ;\)

Witto
(MM club member)
2007-09-18 06:19 PM
Re: Problem with ReadFileTail Function

Are you using KiXtart 4.53?
 Code:
Break On
Dim $
@KIX
Get $


JochenAdministrator
(KiX Supporter)
2007-09-18 08:06 PM
Re: Problem with ReadFileTail Function

Well, of course I am using 4.53, But that's not the point, no?

ddady
(Getting the hang of it)
2007-09-19 11:13 AM
Re: Problem with ReadFileTail Function

Thanx JOCHEN,

You just had to say "@crlf". :-)

I have managed to do it.