MySQL Forums
Forum List  »  Perl

capturing mysql errors with backticks
Posted by: Mike Wood
Date: January 05, 2007 05:49PM

I have a cronned perl script that loads another db's data into my database every morning. The mysql part looks like this:
/usr/local/mysql/bin/mysql -u user -ppassword < load_dbs.sql

It's fairly simple and works most of the time but sometimes it fails. I don't know why it fails and every time I run it manually it works. So I decided to add some error capturing to the mysql call. Essentially I enclosed it in backticks and put the result into a variable.
my $var = `/usr/local/mysql/bin/mysql -u user -ppassword < load_dbs.sql`;

I assumed that the error would show up in the variable (and forces and error with a bad password) but the variable always remains null -- even though when watching it run I can see the error show on the screen. I'm guessing this is because the error I see from mysql is part of it's run and not a return value.

How can I capture what the error is in perl? Or what log can I look in (hours after it happened) to find the error?

Thanks for the help,
Mike

Options: ReplyQuote


Subject
Written By
Posted
capturing mysql errors with backticks
January 05, 2007 05:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.