shell scripting help needed...
I've got the following little PHP script which does what I need it to do, except the needed shell_exec function is disabled so it's no good.So I need to rewrite this little script into shell code. It will run in cron every night .. This is the code:
<?php
$time = date("D, d M Y - H:i", time());
$server_name = "Server1";
$err1 = shell_exec("/usr/sbin/tw_cli alarms | grep -i '\(error\|degraded\)'");
$err2 = shell_exec("/usr/sbin/tw_cli info c0 u0 | grep -i '\(error\|degraded\)'");
if($err1 != '' || $err2 != ''){
$s = mail("blah@blah.com", "3Ware Array PROBLEM ($server_name): $time", "There is a problem with the array on $server_name!<br><br>Log in now and issue tw_cli info c0 u0", "Content-Type: text/html; charset=iso-8859-1\n");
$s2 = mail("blah@blah.com", "3Ware Array PROBLEM ($server_name): $time", "There is a problem with the array on $server_name!<br><br>Log in now and issue tw_cli info c0 u0", "Content-Type: text/html; charset=iso-8859-1\n");
}
?>
Basically what that does is issue a couple of commands and checks their return values and if they contain certain keywords it send an email or 2 ...
Anyone able to translate the above into shell script for me? i use bash shell...