Last active
August 29, 2015 14:10
-
-
Save MMcM/f00108c5943e919f73d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tmux kill-session -t SQL || true | |
tmux new-session -d -n SQL -s SQL "fdbsqlcli test | tee /tmp/SQL0.out" | |
tmux split-window -t SQL "fdbsqlcli test | tee /tmp/SQL1.out" | |
count_prompts() | |
{ | |
grep "=>" /tmp/SQL$1.out | wc -l | |
} | |
wait_for_prompts() | |
{ | |
until [ $2 -ne $(count_prompts $1) ]; do | |
echo -n '.' | |
done | |
} | |
tell() | |
{ | |
BEFORE=$(count_prompts $1) | |
tmux send-keys -t $1 "$2\\;" c-M | |
wait_for_prompts $1 $BEFORE | |
} | |
wait_for_prompts 0 0 | |
wait_for_prompts 1 0 | |
tell 0 "drop table if exists test" | |
tell 0 "create table test (id int primary key, value int)" | |
tell 0 "insert into test (id, value) values (1, 10), (2, 20)" | |
tell 0 "begin" | |
tell 1 "begin" | |
tell 0 "update test set value = 11 where id = 1" | |
tell 1 "update test set value = 12 where id = 1" | |
tell 0 "update test set value = 21 where id = 2" | |
tell 0 "commit" | |
tell 0 "select * from test" | |
tell 1 "update test set value = 22 where id = 2" | |
tell 1 "commit" | |
tell 0 "select * from test" | |
tell 1 "select * from test" | |
tmux attach-session -t SQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment