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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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. |
| ||||
| 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 |
| Thread Tools | |
| Display Modes | |
|
|