从MySQL触发器/存储过程执行Shell脚本/命令 [英] Execute Shell script/command from MySQL Trigger/Stored Procedure

查看:591
本文介绍了从MySQL触发器/存储过程执行Shell脚本/命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在上学期的主要课程(IT与网络工程学)中写我的主要作业,并且目前正在与MySQL合作.

I'm currently writing my Main Assignment on my last semester at my study (IT-Engineering with Networking) and currently working with MySQL.

我的问题是:是否可以从MySQL触发器/过程中执行Shell脚本/命令?还是可以从CASE语句中完成? 我一直在互联网上搜索,但阅读它不建议这样做. 但是我需要一个脚本来检查数据库中的表是否有警报,然后警告人们是否有警报. 如果还有其他方法可以做到,那么我很愿意提出想法. 任何输入将不胜感激:)

My question is: Is it possible to execute a Shell script/Command from within a MySQL Trigger/Procedure? Or can it be done from a CASE statement? I've been searching around the internet and read that it's inadvisable to do it. But I need a script to check a table in a database for alerts and then warn people if there is any. If there is anyway else this could be done, then I'm open for ideas. Any input will be appreciated :)

推荐答案

您可以阅读此博客,了解如何从MySQL触发Shell脚本: https://patternbuffer.wordpress.com/2012/09/14/triggering-shell-script-from-mysql/

You can read this blog for triggering a shell script from MySQL: https://patternbuffer.wordpress.com/2012/09/14/triggering-shell-script-from-mysql/

我认为,根据您的需求,只需编写一个python/php/perl脚本,它将连接您的MySQL数据库并查询警报表中是否有任何警报,并相应地在屏幕上显示警告消息或发送电子邮件/短信警告.

I think for your requirement just write a python/php/perl script which will connect your MySQL DB and query the alert table for any alert and accordingly show warning message on the screen or send email/sms warning.

这篇关于从MySQL触发器/存储过程执行Shell脚本/命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆