I am running a sybase stored proc from perl with lots of print statements, How do I retrieve these print statements into a logfile?
I am running a sybase stored proc from perl with lots of print statements, How do I retrieve these print statements into a logfile? pl let me know the syntax
Sybase DatabasePerl
Last Comment
grant300
8/22/2022 - Mon
rowansmith
Can you not just use the output redirector? Are you executing this in a shell?
perlscript_command > filename.txt
Now all the print statements will be written to the file.
-Rowan
chp123
ASKER
These are not the outputs from the perlscript, These are the debug statements used in the print statements of Sybase procedure. This Sybase procedure is called from a perlscript. We want to log the print statements from the Sybase into a logfile as this perl scrpt is fired as part of an eod job. This logfile can subsequently be used to trace the execution path.
Joe Woodhouse
Sybase ASE's print statement is handled differently by each client tool. I'm not sure how Perl treats these. You will have a more repeatable result if you use SELECTs instead...
That's a good point, I think print statements are usually considered part of STDERR.
chp123
ASKER
Thanks for sharing the links. The solution proposed seems to be a generic one for reading any stderr/stdou. I was looking for something simpler that allows me to send "debug log" statements from a sysbase stored procedure to perl which eventually need to be writtent to some kind of trace/log file. I found below link that seems to address my need, but the entire solution is not clear, can some pls. share the details: https://www.experts-exchange.com/questions/21373589/Printing-from-stored-procedure-to-perl.html
>I was looking for something simpler that allows me to send
>"debug log" statements from a sysbase stored procedure
O.K. now I'm a bit confused. Can you please tell us HOW do you run/call the stored procedure though perl? It will help to understand what you are doing and what you need.
It's not about "catching" the output of print in the stored procedure, but about a way to get direct return data from the stored procedure. Maybe that's even better than any print statements. Can you tell us why you would need the print statements?
Kurt
chp123
ASKER
I need to to create an application log file when the procedure is executing so as to monitor the processing being done . Currently I use "print xxx" commands in my sybase procedure that come on the console when I run as standalone through AquaData Studio. When the same procedure is run through PERL I need the output to come to a log file, I run the procedure through perl using following code:
my $sql = qq{ exec TestProc };
....
my $dbRows = $dbh->sql($sql);
..
If you put your diagnostic statements in SELECTs, they will be in STDOUT and Perl can easily capture them.
Mind you it seems it's about the same amount of work to capture STDOUT as it is STDERR...
kukno
again, can you please tell us HOW do you run/call the stored procedure though perl? What DB interface do you use? It depends on that interface if it is possible to capture STDOUT of a stored procedure!
perlscript_command > filename.txt
Now all the print statements will be written to the file.
-Rowan