Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2000-12

Error messages again

11 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lindmayer Antal

Hi!

I asked a few days ago how to redirect error messages from std i/o to file. Your answer was: run the program with arguments. My problem is: The program is a web-server application, and if there is an error while the program is running the error message will be displayed in the browser. Becouse this program is an web-server application, I can't run it with arguments...

Please help me!

LATte

Michael Van Canneyt
to Lindmayer Antal
Lindmayer Antal wrote
Hi! I asked a few days ago how to redirect error messages from std i/o to file. Your answer was: run the program with arguments.

The solution is to close stderr and to re-open it to a file:

  Close(stdErr);
  Assign(stderr,'somefile');
  rewrite(stderr);
  // now all errors go to somefile...

Make sure you have write permission on somefile.

Michael.

Unknown author
to Lindmayer Antal: Hi! I asked a few days ago how to redirect error messages from std i/o to file. Your…
Show quoted text 10 lines
Hi! I asked a few days ago how to redirect error messages from std i/o to file. Your answer was: run the program with arguments. My problem is: The program is a web-server application, and if there is an error while the program is running the error message will be displayed in the browser. Becouse this program is an web-server application, I can't run it with arguments... Please help me!

What type of error message (run time, etc)

Javier Morquecho Morquecho
to Unknown author

Hi...

I'm using Postgres and the Linux Unit, right now I call a field by his field number, something like :
PQgetvalue(res, i, 1);

	But I would like to use the field name...some like :
PQgetvalue(res, i, my_field);
	I guess there is another function, any tip ???....

Thanks.....

Ing. Morquecho Morquecho
Cedetel
Desarrollo de proyectos comerciales
Tel : 177-10-87
Cel : 177-00-87
e-mail :
e-movil :
Home Cedetel : http://www.cedetel.com.mx

"#define QUESTION ((bb) || !(bb)) // Shakespeare"

Ken J. Wright
to Javier Morquecho Morquecho
you wrote 8 lines
Hi... I'm using Postgres and the Linux Unit, right now I call a field by his field number, something like : PQgetvalue(res, i, 1); But I would like to use the field name...some like : PQgetvalue(res, i, my_field);
PQgetvalue(res, i, PQfnumber(res,'fieldname'));
Dirk Verwiebe
to Michael Van Canneyt: The solution is to close stderr and to re-open it to a file: Close(stdErr);…

I tried it under win98 in a dos box (go32v2) with snapshot from today and get only a file with length 0 byte.The error message appeard on the screen.

close(stderr);
assign(stderr,'err.txt');
rewrite(stderr);
mem[$fffff]:=0;

Dirk

Show quoted text 16 lines
On Tue, 19 Dec 2000, Lindmayer Antal wrote: The solution is to close stderr and to re-open it to a file: Close(stdErr); Assign(stderr,'somefile'); rewrite(stderr); // now all errors go to somefile... Make sure you have write permission on somefile. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Adam Naumowicz
to Dirk Verwiebe
Dirk Verwiebe wrote 8 lines
I tried it under win98 in a dos box (go32v2) with snapshot from today and get only a file with length 0 byte.The error message appeard on the screen. close(stderr); assign(stderr,'err.txt'); rewrite(stderr); mem[$fffff]:=0;

Haven't you forgotten to close the stderr file after writing to it ?

Adam Naumowicz

--------------------------------------
WWW: http://math.uwb.edu.pl/~adamn/
--------------------------------------

Dirk Verwiebe
to Adam Naumowicz

i had a close in the exithandler. But i removed it because i think freepascal makes a close, too.

Dirk Verwiebe

Show quoted text 22 lines
On Tue, 19 Dec 2000, Dirk Verwiebe wrote: > I tried it under win98 in a dos box (go32v2) with snapshot from today and > get only a file with length 0 byte.The error message appeard on the screen. > > close(stderr); > assign(stderr,'err.txt'); > rewrite(stderr); > mem[$fffff]:=0; > Haven't you forgotten to close the stderr file after writing to it ? Adam Naumowicz -------------------------------------- WWW: http://math.uwb.edu.pl/~adamn/ -------------------------------------- _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Kuba Ober
to Adam Naumowicz: Haven't you forgotten to close the stderr file after writing to it ? Adam Naumowicz…
Show quoted text 10 lines
> I tried it under win98 in a dos box (go32v2) with snapshot from today and > get only a file with length 0 byte.The error message appeard on the > screen. > > close(stderr); > assign(stderr,'err.txt'); > rewrite(stderr); > mem[$fffff]:=0; Haven't you forgotten to close the stderr file after writing to it ?

Seems that the message was being written to stdout and not stderr... Make sure that it indeed goes to stderr.
Kuba

Dirk Verwiebe
to Kuba Ober
> Haven't you forgotten to close the stderr file after writing to it ?

I have installed an exit handler,too.There is the stderr closed. The exit handler was correctly called when the error occurs but the file is still 0 byte.

Seems that the message was being written to stdout and not stderr... Make sure that it indeed goes to stderr.

The message is apears on screen.I thought the lines above redirect it to stderr.

Dirk

Kuba Ober
to Dirk Verwiebe
Show quoted text 11 lines
> > Haven't you forgotten to close the stderr file after writing to it ? I have installed an exit handler,too.There is the stderr closed. The exit handler was correctly called when the error occurs but the file is still 0 byte. > Seems that the message was being written to stdout and not stderr... Make > sure that it indeed goes to stderr. The message is apears on screen.I thought the lines above redirect it to stderr.

Well, what I mean is that you should make sure that whatever code writes the message, it writes it to stderr. The code redirects stderr to the file, but if you write the message to stdout it won't help much, right?

Kuba