Exit codes; Prevent infinite loops

Added exit code for shell script error handling (e.g. fetch SMW data periodically from cron job); trimmed contents to prevent infinite loops