how to redirect a error returned from mysql syntax

Following is a shell file in linux. I am executing a mysql query from the file. I want the error from the execution to be redirected to a file.
The present redirection does not redirect the mysql errors.

#!/bin/sh
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 95 10

mysql -u${MYSQL_ROOT_USER} -p${MYSQL_ROOT_PASSWORD} -e "show tables in omcr;" 1>/dev/null 2>&1
   isTables=$?
   if [ $isTables -ne 0 ] ; then
      dexist=0
   fi
pvinodpAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omarfaridCommented:
it is redirecting to /dev/null which is pasically to ignore or trash the output and errors. You may do it like

mysql -u${MYSQL_ROOT_USER} -p${MYSQL_ROOT_PASSWORD} -e "show tables in omcr;" 1>/dev/null 2> /path/to/mysql_errors
0
pvinodpAuthor Commented:
it does not work.. i still get error prompted on to my screen
0
AwesomeMachineCommented:
Ok, if you want to see the program output, but not the errors, you want to change that to

omcr;" &2>~/errors.txt

If you don't want program output, but you do want error redirection
omcr;" &1> /dev/null &2>~errors.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
point_pleasantCommented:
possibly the problem is with mysql try inside mysql:

mysql> pager '/dev/null'
0
pvinodpAuthor Commented:
I have managed to rewrite the sql query which will not generate a error. thanks anyways
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.