echo "select * from users" |mysql myride --skip-column-names|awk {'print $1'}
martes, 22 de noviembre de 2011
Creating a HashBang wrapper
Some time ago I needed an executable that was able to call SQL sentences with mysql or sqlite. I did a little research to understand how Shebang works, I found out that was very easy to write your custom wrappers
wrapper :: /bin/bmysql#!/bin/bash export database=$1 #echo "Database:: $1| SQL: $2" #echo $1 holds the file where sql data is stored export sql_data=`cat $2|grep -v \"#!\"` #echo "DEBUG:: $sql_data " echo $sql_data|mysql $1 echo $?
and the script file /home/test/demo.sql
#!/bin/bmysql drupal show databases;Have fun with your own wrappers!!!
Suscribirse a:
Entradas (Atom)