Unix Technical Forum

spool data/log into a file.

This is a discussion on spool data/log into a file. within the MySQL General forum forums, part of the MySQL category; --> Hi All, I have written a script to connect to mysql and all the command results is spooled into ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:15 AM
Ananda Kumar
 
Posts: n/a
Default spool data/log into a file.

Hi All,
I have written a script to connect to mysql and all the command results is
spooled into a file.
But when an error occurs in mysql, it stops at that point and does not
proceed to the next command, also these error command is not written to the
output file.

Can you please tell me what i need to do, for the script to continue even if
there is an error and that these errors should be spooled into a file.

I have used -f(force) option while connecting to mysql db, it continues even
if there is any error in the script, but it does not write error command
into the output file. Can you please help how can i spool all the output
into a file.
Below is the simple script i am using, ttt.txt is the file which will
contain the all the output of the script.

mysql -u -p -f << eof | tee ttt.txt

use dev1;
select count(*) from rep_abc;
select count(*) from rep_fact;

exit
eof

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:15 AM
mizioumt@netscape.net
 
Posts: n/a
Default Re: spool data/log into a file.

most likely you just need to redirect STDERR to tee as well so it's not
a mysql problem:

mysql -u -p -f << eof 2>&1 | tee ttt.txt
....

assuming it's Bourne or ksh, don't remember what's csh for 2>&1

Regards,
Michael

-----Original Message-----
From: anandkl@gmail.com
To: mysql@lists.mysql.com
Sent: Thu, 26 Apr 2007 8:15 AM
Subject: spool data/log into a file.

Hi All,
I have written a script to connect to mysql and all the command results
is
spooled into a file.
But when an error occurs in mysql, it stops at that point and does not
proceed to the next command, also these error command is not written to
the
output file.

Can you please tell me what i need to do, for the script to continue
even if
there is an error and that these errors should be spooled into a file.

I have used -f(force) option while connecting to mysql db, it continues
even
if there is any error in the script, but it does not write error
command
into the output file. Can you please help how can i spool all the
output
into a file.
Below is the simple script i am using, ttt.txt is the file which will
contain the all the output of the script.

mysql -u -p -f << eof | tee ttt.txt

use dev1;
select count(*) from rep_abc;
select count(*) from rep_fact;

exit
eof
__________________________________________________ ______________________
Check Out the new free AIM(R) Mail -- 2 GB of storage and
industry-leading spam and email virus protection.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 06:17 AM
Joerg Bruehe
 
Posts: n/a
Default Re: spool data/log into a file.

Hi Michale, all


mizioumt@netscape.net wrote:
> most likely you just need to redirect STDERR to tee as well so it's not
> a mysql problem:
>
> mysql -u -p -f << eof 2>&1 | tee ttt.txt
> ...
>
> assuming it's Bourne or ksh, don't remember what's csh for 2>&1


It is an appended '&': prog >& file
prog |& tee ...

But remember this one:
http://www.gregor.com/dgregor/csh_whynot.html

Regards,
Joerg

--
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
Office: (+49 30) 417 01 487 VoIP: 4464@sip.mysql.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com