Skip to content

Commit 63ad6e5

Browse files
Stanislav DakovStanislav Dakov
authored andcommitted
fixed for macos
1 parent 68ad1a5 commit 63ad6e5

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

sshko.sh

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,48 @@ if [[ ! -e ${logFile} ]]; then
77
touch ${logFile}
88
fi
99

10-
if [ "$1" == "" ] || [ $# -gt 1 ];
11-
then
12-
if ! [ -s ${logFile} ];then
10+
if [ "$1" == "" ] || [ $# -gt 1 ]; then
11+
if ! [ -s ${logFile} ]; then
1312
echo "ssh log file is empty"
1413
exit
1514
fi
16-
15+
1716
HEIGHT=20
1817
WIDTH=40
1918
CHOICE_HEIGHT=9
2019
BACKTITLE="This is made, because you are super lazy!!!!"
2120
TITLE="SSHko"
2221
MENU="Choose one of the following ssh connections:"
2322

24-
readarray rows < ${logFile}
25-
#rows2=$(nl ${logFile})
23+
arr=()
24+
val=()
25+
key=0
26+
while IFS= read -r line || [[ "$line" ]]; do
27+
arr+=($key "$line")
28+
val+=("$line")
29+
((key = key + 1))
30+
done <${logFile}
2631

27-
choices=();
28-
for key in "${!rows[@]}";
29-
do
30-
#choices+=($($key+1) "${rows[$key]}");
31-
choices+=($key "${rows[$key]}");
32-
done;
32+
for key in "${!arr[@]}"; do
33+
echo ${arr[$key]}
34+
done
3335

34-
CHOICE=$(whiptail --clear \
35-
--backtitle "$BACKTITLE" \
36-
--title "$TITLE" \
37-
--menu "$MENU" \
38-
$HEIGHT $WIDTH $CHOICE_HEIGHT \
39-
-- "${choices[@]}" \
40-
2>&1 >/dev/tty)
36+
echo ${#arr[@]}
4137

38+
CHOICE=$(dialog --clear --title "$TITLE" --backtitle "$BACKTITLE"\
39+
--menu "$MENU" $HEIGHT $WIDTH $CHOICE_HEIGHT "${arr[@]}" \
40+
2>&1 >/dev/tty)
4241
clear
43-
if [[ ! $CHOICE == "" ]]
44-
then
45-
sshHost=${rows[$CHOICE]}
42+
if [[ ! $CHOICE == "" ]]; then
43+
sshHost=${val[$CHOICE]}
4644
echo "$CHOICE You chose ${sshHost}"
4745
ssh ${sshHost}
48-
#ssh ${sshHost}
4946
fi
5047
else
51-
sshHost=$1;
48+
sshHost=$1
5249
# echo ${sshHost} >> ${logFile}
53-
if ! grep -Fxq "$sshHost" ${logFile}
54-
then
55-
echo ${sshHost} >> ${logFile}
50+
if ! grep -Fxq "$sshHost" ${logFile}; then
51+
echo ${sshHost} >>${logFile}
5652
fi
5753

5854
ssh ${sshHost}

0 commit comments

Comments
 (0)