From 4b4c467eba1b7a2f2662beea79286eb14a4bc0b5 Mon Sep 17 00:00:00 2001 From: michael1 <1790241+michael1@users.noreply.github.com> Date: Tue, 9 Jan 2018 23:38:19 +0100 Subject: [PATCH] Added error handling for failed logins Added error handling for failed logins Moved the get_devlist after the re-login section --- alexa_remote_control.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/alexa_remote_control.sh b/alexa_remote_control.sh index 9c975ff..40158e0 100644 --- a/alexa_remote_control.sh +++ b/alexa_remote_control.sh @@ -612,19 +612,28 @@ if [ -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" fi if [ ! -f ${COOKIE} ] ; then - echo "cookie do not exist. logging in ..." + echo "cookie does not exist. logging in ..." log_in fi -if [ ! -f ${DEVLIST} ] ; then - echo "device list do not exist. downloading ..." - get_devlist -fi - check_status if [ $? -eq 0 ] ; then echo "cookie expired, logging in again ..." log_in + check_status + if [ $? -eq 0 ] ; then + echo "log in failed, aborting" + exit 1 + fi +fi + +if [ ! -f ${DEVLIST} ] ; then + echo "device list do not exist. downloading ..." + get_devlist + if [ ! -f ${DEVLIST} ] ; then + echo "failed to download device list, aborting" + exit 1 + fi fi if [ -n "$COMMAND" -o -n "$QUEUE" ] ; then