If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Call Shell Function from mysql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-18-11, 05:17
santhoshvkumar santhoshvkumar is offline
Registered User
 
Join Date: Apr 2011
Posts: 3
Call Shell Function from mysql

Hi all,
I am trying a scenario for calling a shell script when ever a trigger is called. Can some one guide me how to achive this scenario. Also it should passes the value from the table to the shell script. Can some one explain me along with the example.

Thanks in Advance,
Santhosh V Kumar.
Reply With Quote
  #2 (permalink)  
Old 04-18-11, 06:20
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by santhoshvkumar View Post
I am trying a scenario for calling a shell script when ever a trigger is called. Can some one guide me how to achive this scenario.
I'm pretty sure you can't do this but, even if you could, it would kill performance.

Normal approach would be to write data to a table with a timestamp then the shell script would look for data in the table that had arrived after it last ran. Improvements to this might include:
  • Not updating the time if there's any errors.
  • The time it last ran can be stored as a heartbeat which also shows you the process is running.
  • Sending an email to a support group if there's any errors.
  • Having a maximum amount of data it can process at any one go to avoid locking etc.
  • Altering how often it polls the table depending on how much data it finds.
  • Removing the triggers and then accessing the data direct.
__________________
Mike
Reply With Quote
  #3 (permalink)  
Old 04-18-11, 07:22
santhoshvkumar santhoshvkumar is offline
Registered User
 
Join Date: Apr 2011
Posts: 3
can you tell me some example

Can.. you please tell me some simple example. I am checking for past one week.
Reply With Quote
  #4 (permalink)  
Old 04-18-11, 08:03
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by santhoshvkumar View Post
Can.. you please tell me some simple example. I am checking for past one week.
What have you managed to create in past week and we'll go from there.
__________________
Mike
Reply With Quote
  #5 (permalink)  
Old 04-19-11, 08:19
santhoshvkumar santhoshvkumar is offline
Registered User
 
Join Date: Apr 2011
Posts: 3
Setup Database

Hi,
I actually got an database which consist of 3 column the things it will get the data from a web application and I need to read the column that last affected in the database. and I need to read it through a shell or any program and need to store it in a file system. inorder for some other computation. I developed a code with shell script to do this process. Also I called with mysql >! someshell.sh its working fine. but when ever there is a update in table how to achive it. Please help me with this.

With Regards,
Santhoshvkumar
Reply With Quote
  #6 (permalink)  
Old 04-19-11, 11:26
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Just update a timestamp each time you insert or update a record.

Then in your shell script select any data from the table that has a timestamp older than the last time you pulled data from the table.
__________________
Mike
Reply With Quote
Reply

Tags
mysql, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On