@@ -15,21 +15,36 @@ if [ -z "$1" ] || [ -z "$2" ]; then
1515 exit 1
1616fi
1717
18- set -e
18+ # Check if tmux is available
19+ which tmux
20+ RESULT=$?
21+ if [ ${RESULT} = 1 ]; then
22+ echo " tmux is not installed!!"
23+ exit 1
24+ fi
25+
1926echo " Creating tmux session at $PWD with command :"
20- tmux new-session -d -s test " $TEST_CLIENT -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \" $1 \" -p \" $2 \" "
27+ echo " tmux new-session -d -s test \" $TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \" $1 \" -p \" $2 \"\" "
28+ tmux new-session -d -s test " $TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \" $1 \" -p \" $2 \" "
29+ echo " Result of tmux new-session = $? "
2130
2231# give the command a second to establish SSH connection
23- sleep 0.5
32+ sleep 1
2433
2534COL=` tmux display -p -t test ' #{pane_width}' `
2635ROW=` tmux display -p -t test ' #{pane_height}' `
36+ echo " tmux 'test' session has COL = ${COL} and ROW = ${ROW} "
2737
2838# get the terminals columns and lines
2939tmux send-keys -t test ' echo;echo $COLUMNS $LINES;echo'
3040tmux send-keys -t test ' ENTER'
41+
42+ # give the command a second to run
43+ sleep 1
44+
3145tmux capture-pane -t test
3246RESULT=$( tmux show-buffer | grep ' ^[0-9]* [0-9]*$' )
47+ tmux show-buffer
3348
3449echo " $RESULT "
3550echo " "
5570# close down the SSH session
5671tmux send-keys -t test ' exit'
5772tmux send-keys -t test ' ENTER'
58- set +e
5973
6074# kill off the session if it's still running, but don't error out if the session
6175# has already closed down
6276tmux kill-session -t test
6377set -e
6478
65- tmux new-session -d -x 50 -y 10 -s test " $TEST_CLIENT -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \" $1 \" -p \" $2 \" "
79+ echo " Starting another session with a smaller window size"
80+ echo " tmux new-session -d -x 50 -y 10 -s test \" $TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \" $1 \" -p \" $2 \"\" "
81+ tmux new-session -d -x 50 -y 10 -s test " $TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \" $1 \" -p \" $2 \" "
6682
6783# give the command a second to establish SSH connection
68- sleep 0.5
84+ sleep 1
6985
86+ echo " Sending keys to tmux session for displaying column/rows"
7087tmux send-keys -t test ' echo;echo $COLUMNS $LINES;echo'
7188tmux send-keys -t test ' ENTER'
7289tmux capture-pane -t test
7390RESULT=$( tmux show-buffer | grep ' ^[0-9]* [0-9]*$' )
7491
75- ROW_FOUND=$( echo " $RESULT " | sed -e ' s/[0-9]* \([0-9]*\)/\1/' )
76- COL_FOUND=$( echo " $RESULT " | sed -e ' s/\([0-9]*\) [0-9]*/\1/' )
92+ ROW_FOUND=$( echo " $RESULT " | sed -e ' s/[0-9]* \([0-9]*\)/\1/' )
93+ COL_FOUND=$( echo " $RESULT " | sed -e ' s/\([0-9]*\) [0-9]*/\1/' )
94+
95+ # remove any newlines, tabs, or returns
96+ ROW_FOUND=$( tr -d ' \n\t\r ' <<< " $ROW_FOUND" )
97+ COL_FOUND=$( tr -d ' \n\t\r ' <<< " $COL_FOUND" )
98+
7799
78100if [ " 50" != " $COL_FOUND " ]; then
79101 echo " Col found was $COL_FOUND which does not match expected 50"
0 commit comments