From: Florent Bruneau Date: Sat, 10 Nov 2007 15:12:49 +0000 (+0100) Subject: Add a small command line tool to get information about a user. X-Git-Tag: xorg/0.9.16~214 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=5c110c68f7064accfbb7c2ca4a3e02c31947e85e;p=platal.git Add a small command line tool to get information about a user. Just run ./getuser.sh "fields" "Name" ["promo"] eg.: ./getuser.sh user_id "F B" 2003 will output Signed-off-by: Florent Bruneau --- diff --git a/bin/getuser.sh b/bin/getuser.sh new file mode 100755 index 0000000..30e6377 --- /dev/null +++ b/bin/getuser.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +field=$1 +nom=$2 +promo=$3 + +query="SELECT $field FROM auth_user_md5 AS u " +where="" +pos=0 +for i in $nom ; do + query="$query INNER JOIN search_name AS sn${pos} ON (u.user_id = sn${pos}.uid) " + [ "$where" != "" ] && where="$where AND" + where="${where} sn${pos}.token LIKE \"${i}%\"" + pos=$((pos + 1)) +done +if [ "${promo}" != "" ] ; then + [ "$where" != "" ] && where="$where AND " + where="${where} u.promo = $promo" +fi +query="${query} WHERE ${where} GROUP BY u.user_id" + +echo $query | mysql --default-character-set=utf8 -N x4dat