-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample1.sh
executable file
·77 lines (62 loc) · 1.85 KB
/
example1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
mkdir example1
touch ./example1/client1.txt
touch ./example1/client2.txt
# Start a new Tmux session named 'multi_terminal'
tmux new-session -d -s example1
# Split the window into multiple panes
tmux split-window -h
tmux split-window -v
# Send commands to the panes (adjust commands as needed)
tmux send-keys -t 0 'nc localhost 8888 1>./example1/client1.txt' C-m
tmux send-keys -t 1 'nc localhost 8888 1>./example1/client2.txt' C-m
tmux send-keys -t 0 'register' C-m
sleep 0.05
tmux send-keys -t 0 'register ta1 420420' C-m
sleep 0.05
tmux send-keys -t 0 'register ta1 420420' C-m
sleep 0.05
tmux send-keys -t 0 'login' C-m
sleep 0.05
tmux send-keys -t 0 'login ta1' C-m
sleep 0.05
tmux send-keys -t 0 'login ta1 000000' C-m
sleep 0.05
tmux send-keys -t 0 'login Tom 420420' C-m
sleep 0.05
tmux send-keys -t 0 'login ta1 420420' C-m
sleep 0.05
tmux send-keys -t 0 'whoami' C-m
sleep 0.05
tmux send-keys -t 0 'login ta1 420420' C-m
sleep 0.05
tmux send-keys -t 0 'logout' C-m
sleep 0.05
tmux send-keys -t 0 'logout' C-m
sleep 0.05
tmux send-keys -t 0 'register ta2 777777' C-m
sleep 0.05
tmux send-keys -t 1 'register ta3 ta3' C-m
sleep 0.05
tmux send-keys -t 1 'login ta3 ta3' C-m
sleep 0.05
tmux send-keys -t 1 'list-user' C-m
sleep 0.05
tmux send-keys -t 0 'exit' C-m
sleep 0.05
tmux send-keys -t 1 'set-status happyhappy' C-m
sleep 0.05
tmux send-keys -t 1 'set-status busy' C-m
sleep 0.05
tmux send-keys -t 1 'list-user' C-m
sleep 0.05
tmux send-keys -t 1 'exit' C-m
sleep 0.05
# tmux send-keys -t 2 "echo '============== Example1 =============='" C-m
tmux send-keys -t 2 'diff ./example1/client1_ans.txt ./example1/client1.txt' C-m
tmux send-keys -t 2 'diff ./example1/client2_ans.txt ./example1/client2.txt' C-m
# Attach to the Tmux session to view the created panes
tmux attach-session -t example1