Page 1 of 1 1
Topic Options
#180663 - 2007-09-18 09:07 AM Problem with ReadFileTail Function
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
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.

Top
#180664 - 2007-09-18 09:12 AM Re: Problem with ReadFileTail Function [Re: ddady]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#180666 - 2007-09-18 09:21 AM Re: Problem with ReadFileTail Function [Re: ddady]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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")
_________________________



Top
#180667 - 2007-09-18 10:35 AM Re: Problem with ReadFileTail Function [Re: Jochen]
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
Mart, sorry i didn't know, wont happen again.

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

Top
#180668 - 2007-09-18 10:47 AM Re: Problem with ReadFileTail Function [Re: ddady]
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
That's is the error i'm getting

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

Top
#180669 - 2007-09-18 10:51 AM Re: Problem with ReadFileTail Function [Re: ddady]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
 Originally Posted By: ddady
Mart, sorry i didn't know, wont happen again.
....


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

- Chuck Norris once sold ebay to ebay on ebay.

Top
#180670 - 2007-09-18 11:14 AM Re: Problem with ReadFileTail Function [Re: ddady]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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
_________________________



Top
#180671 - 2007-09-18 01:29 PM Re: Problem with ReadFileTail Function [Re: Jochen]
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
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()

Top
#180672 - 2007-09-18 01:44 PM Re: Problem with ReadFileTail Function [Re: ddady]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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


Edited by Mart (2007-09-18 01:45 PM)
Edit Reason: Typo.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#180673 - 2007-09-18 03:05 PM Re: Problem with ReadFileTail Function [Re: Mart]
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
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 ????????

Top
#180674 - 2007-09-18 03:39 PM Re: Problem with ReadFileTail Function [Re: ddady]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hmm ... maybe a character in the file that causes readline to choke on (It is designed to read ASCII files only)
_________________________



Top
#180676 - 2007-09-18 04:26 PM Re: Problem with ReadFileTail Function [Re: Jochen]
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
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.

Top
#180677 - 2007-09-18 04:29 PM Re: Problem with ReadFileTail Function [Re: ddady]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Show some code and one of us will place some @crlf macros in it ;\)
_________________________



Top
#180682 - 2007-09-18 06:19 PM Re: Problem with ReadFileTail Function [Re: Jochen]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Are you using KiXtart 4.53?
 Code:
Break On
Dim $
@KIX
Get $

Top
#180690 - 2007-09-18 08:06 PM Re: Problem with ReadFileTail Function [Re: Witto]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Well, of course I am using 4.53, But that's not the point, no?
_________________________



Top
#180721 - 2007-09-19 11:13 AM Re: Problem with ReadFileTail Function [Re: Jochen]
ddady Offline
Getting the hang of it

Registered: 2006-09-03
Posts: 98
Thanx JOCHEN,

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

I have managed to do it.

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
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.109 seconds in which 0.061 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