January 15, 2014

watch SQL script.


The following script is a way to execute a mysql command every second. I wrote the script because OSX doesn't have a watch command and mysql takes the SQL statement from stndin.





#!/bin/bash

SQL=`cat -`

while true;
do
   clear
   echo $SQL
   echo "$SQL" | mysql $*
   date
   sleep 1

done

No comments: