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 > Execute shell script through stored procedure

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-22-10, 06:14
ankur02018 ankur02018 is offline
Registered User
 
Join Date: Jun 2007
Posts: 189
Smile Execute shell script through stored procedure

Hi ,

I want to execute shell script through stored procedure if condition matches

DELIMITER $$
CREATE PROCEDURE CheckStatus()
BEGIN
DECLARE state INT DEFAULT 0;
select count(*) into state from test_done where status=0 or status='';
IF state > 0
THEN

sh /usr/bin/testshell.sh

ELSE

exit from mysql prompt

END IF;
END $$
DELIMITER ;
Reply With Quote
  #2 (permalink)  
Old 02-22-10, 06:27
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,517
Probably better to create a function in MySQL to just return the status. Then get the shell script to call the MySQL function before doing anything else. If the function returns false then quit the script else continue with whatever the script normally does. If you need to run this regularly then call the script from cron.

Mike
Reply With Quote
Reply

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