executing mysql load statement from shell script

Hi,

 I have a piece of shell script which will connect to mysql database and execute a load statement\(which will load datas in a file to the database table\).The code is working and the data is in the tables.

Now my requirement is, i need to grab the output from the load statement execution whether it will be a success message or failure.If in case the load statement fail i will get the below information while executing from cmd line.

mysql> load data local infile test.txt' into table userdata;
Query OK, 0 rows affected, 14800 warnings (0.05 sec)
Records: 3762 Deleted: 0 Skipped: 3762 Warnings: 14800

I need the same info when am doing this operation from a shell script.
Your help is appreciated!

With Regards
Dileep Pattayath

When using that in a shell script like for example:

mysql -uroot -psomepass mydb < dothat.sql

... you can always check with the shell variable $? what happened; just echo it. 0 is success, 1 is a fail. If you need more verbose output, man mysql says add a -v or -vv or -vvv. -vvv should be as detailed as if doing that interactive on the mysql prompt.

Thats perfect! Thanks a lot mate.

Do you know how we can see the skipped records from a load statement. Like in Oracle we can specify a dsc file or bad file from which we can track the rejected or discarded records, like that anything in mysql?

With Regards
Dileep Pattayath

No idea, but check it out: http://dev.mysql.com/doc/refman/5.0/en/load-data.html

I did it, haven't found anything.
Anyway let's keep on trying.if you got any idea or info about this,please update this thread

Thanks mate, you provided very useful information.

With Regards
Dileep Pattayath