#!/bin/bash progname=mosquitto_sub hostname="master.iot-yun.club" port=10883 uid="lingyun" pwd="lingyun-emb" dltopic="\$Sys/Studio/Downlink" uptopic="\$Sys/Studio/Uplink" sub_command="$progname -h $hostname -p $port -u $uid -P $pwd -t " topics=("" "$uptopic" "$dltopic" ) echo "" echo "Please select a subscribe topic:" echo "1, < Uplink Topic >: Device ---> Server message" echo "2, : Server ---> Device message" echo "" stty erase '^H' read -p "Enter your choise [1/2] : " choice if [ $choice -gt 2 ] ; then echo "ERROR: Invalid input choice, exit now..." exit 1; fi topic=${topics[$choice]} set -x $sub_command $topic