Skip to content

Instantly share code, notes, and snippets.

@AgentCoop
Created January 16, 2014 14:00
Show Gist options
  • Save AgentCoop/8455450 to your computer and use it in GitHub Desktop.
Save AgentCoop/8455450 to your computer and use it in GitHub Desktop.
Backofifce for the poor, i.e. start-ups
1 #! /usr/bin/bash
2
3 query_exec ()
4 {
5 # ssh -T for remote SSH connection
6 echo "$1" | mysql -uroot -proot -N test
7 }
8
9 employees=$(query_exec 'SELECT id,id,firstname,lastname,age FROM `employee` test')
10
11 result=$(zenity --title "Select user to fire" --list --checklist --column "" --column "id" --column "Firstname" --column "Lastname" --column "Age" $employees)
12
13 (
14 IFS='|';
15 for id in $result; do
16 # Fire employee
17 echo " - Deleting employee #$id"
18 $(query_exec "DELETE FROM employee WHERE id = $id")
19 echo " - done"
20 done
21 )
22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment