tfabris / CrowCam

A set of Bash scripts to control and maintain a YouTube live cam from a Synology NAS.
GNU General Public License v3.0
3 stars 3 forks source link

Sunrise/Sunset seems to have some kind of very subtle bug #81

Closed tfabris closed 5 months ago

tfabris commented 5 months ago

During the 2pm hour every day, my log repeats this message every time CrowCam.sh runs:

CrowCam Controller - Problem obtaining sunrise/sunset from Google. Falling back to previously saved values: 7:07 AM/7:24 PM

However when I run the script from the Bash shell (regardless of what system I run it upon or what user I run it under) then the retrieval works.

(Note: This is after I already made the parsing fix which works around google changing the space from a regular space to a nonbreaking space).

Get to the bottom of this!

tfabris commented 5 months ago

Fixed in checkin c700694.

WEIRD solution. To fix this, I had to turn on extended regex (-E), and instead of searching for a single weird unicode character ("."), I had to search for 1-3 characters (".{1,3}"). This was only necessary when running under the Synology Task Scheduler; the problem didn't manifest itself when running on the Synology at the SSH shell prompt.

tfabris commented 5 months ago

Reopening this bug. The previous fix was a mere workaround. The actual fix is related to the linux "locale" variable, LC_ALL. Details in this EmpegBBS thread: https://empegbbs.com/ubbthreads.php/topics/374308 - For some reason, the locale is set correctly, to en_US.utf8, when running from the shell, but it's set to blank/null when running from the Synology Task Scheduler. The fix code looks something like this:

forceLocale="en_US.utf8"
# Force the value of the locale variable:
echo ""
echo "Previous Locale:   $LC_ALL"
echo "Forcing locale to: $forceLocale"
export LC_ALL=$forceLocale
echo "Current Locale:    $LC_ALL"
echo ""

Cause of bug:

I had previously implemented a workaround which searched for 1-3 characters in that slot, but that's a bad grep which could potentially result in false positives. So I'm going to fix this properly, by forcing the locale, at the same time as I fix issue #84 and make additional improvements to the grep.

tfabris commented 5 months ago

Fixed in checkin 2f3ce99