The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Executing a Oracle SQL statement in a UNIX script ganga.dharan Shell Programming and Scripting 1 12-08-2008 10:44 AM
Need help in wrting Load Script for a Load-Resume type of load. ankitgupta Shell Programming and Scripting 1 11-10-2006 12:46 AM
Executing a Shell Script igandu UNIX for Dummies Questions & Answers 4 08-17-2006 10:29 AM
How to write DB2 Load Utility in Shell script parisbeginner Shell Programming and Scripting 0 03-10-2006 02:25 PM
Shell script is not executing dreams5617 UNIX for Advanced & Expert Users 5 08-20-2004 11:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-22-2009
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Post 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
  #2 (permalink)  
Old 01-22-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
When using that in a shell script like for example:
Code:
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.
  #3 (permalink)  
Old 01-22-2009
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Thumbs up

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
  #4 (permalink)  
Old 01-22-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
No idea, but check it out: http://dev.mysql.com/doc/refman/5.0/en/load-data.html
  #5 (permalink)  
Old 01-22-2009
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Thumbs up

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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0