Skip to content

Commit 15494f8

Browse files
authored
Fixed exiting program on case 3
1 parent 02520d8 commit 15494f8

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

python-fileShare.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ HN="hostname -I"
2525
res=$(eval $HN)
2626
arrIN=(${res// / })
2727
IP=""
28+
#TODO:Make GetPort function that takes either user input or cmdline argument for custom port
29+
PORT=8099
2830

2931
#if there is more than one IP available, list the first two as options
3032
#TODO: make a way to list all options
@@ -34,19 +36,24 @@ if [ ${#arrIN[@]} -gt 1 ]; then
3436
select opt in "${options[@]}"
3537
do
3638
case $opt in
39+
#Selecting "1" will assign the first IP to $IP
3740
"${arrIN[0]}")
3841
IP="${arrIN[0]}"
3942
break
4043
;;
41-
44+
#Selecting "2" will assign the second IP to $IP
4245
"${arrIN[1]}")
4346
IP="${arrIN[1]}"
4447
break
4548
;;
49+
#Selecting "3" will exit the program
4650
"Quit")
47-
break
51+
exit 0
52+
;;
53+
54+
#Any input other than 1-3 will result in this error message
55+
*) echo "Invalid option: $REPLY"
4856
;;
49-
*) echo "Invalid option: $REPLY";;
5057
esac
5158
done
5259
else
@@ -56,17 +63,18 @@ fi
5663
echo ""
5764
echo "IP: "$IP
5865
echo ""
59-
echo -e "File links...\n"
66+
echo -e "Download files using these links:\n"
6067
for entry in `ls`;do
6168
if [ ! -d $entry ];then
6269
wgetCmd=$(echo "wget http://${IP##*( )}:8099/$entry" | xargs)
6370
echo -e "\t$GN$wgetCmd$RES"
6471
fi
6572
done
6673
echo ""
67-
echo -e "\nCurrent Directory Contents"
74+
echo -e "\nCurrent Directory Contents:"
6875
ls --color .
6976
echo ""
70-
echo -e "\nStarting Server"
77+
echo -e "\nStarting Server..."
7178

72-
python3 -m http.server 8099 -d .
79+
#Opens HTTP Server in the folder the command is run from on port $PORT
80+
python3 -m http.server $PORT -d .

0 commit comments

Comments
 (0)