Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2007
    Posts
    197

    Smile Unanswered: 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 ;

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •