Closed cgalpin closed 6 years ago
No, thank you!
BTW, the files all have dos line endings (CRLF) which is a bit annoying on the pi. I converted them all using
perl -pi -e 's/\r\n/\n/g' filename
in case you want to switch them to unix line endings.
Thats odd, I wonder why the original contributor did that? I'm like you I always use Unix endings.
BTW theres a command on Linux dos2unix which converts files, easier to remember than the perl ;)
Haha, actually I'm old, so the perl muscle memory is still there and it's my goto for things like this :)
But I do know about do2unix. I don't think it's installed by default in raspian so people will have to apt-get install it first if they want to go this route.
Very odd on the line endings being DOS style, I agree.
Another odd thing is the shutdown command didn't seem to shutdown the pi from the script. The log shows 3 calls to shutdown, a few minutes apart, before I assume the battery died. The command is correct and worked fine cut and pasted on the command line, just not from cron. I'm not sure how it could not work from the script, given the full path and it's running as root. I guess I'll do some more testing. Right now I need to figure out how to detect when the usb power has gone off since all I want to do is sync up and shutdown right away anyway.
Being able to remember Perl must be really useful, I can never use it without a cheat sheet :) The shutdown must be a permissions or path thing I'm guessing?
I'm the same way with sed and awk so just use perl as soon as things get heavy. It's a bit lazy, but it works for me :)
Yes I agree, but I think both are covered. The cron job runs a root, and the full path of shutdown is bing used. Really odd.
Thanks!