OK. I solved my problem.
- Apparently, when you create a file under Windows and move to the Pi, it puts unwanted characters in the file. I removed the sdown.sh file on the Pi, and recreated it with Nano. I then tested it on a command line, and it worked fine. I need to further investigate this further because I want to write some Python on the PI using editors under Windows.
- Another error in the Octoprint Server->Shutdown field, I was using sudo /home/pi/sdown.sh, and it wasn't working. I removed the sudo, and the shutdown script works fine under Octoprint
Now when I shut down Octoprint, after 15 seconds, the printer power supply shuts down, shutting down both the printer and the Pi. Just what I want.
Yeah, these are known as line endings. Linux and Windows don't use the same type so you have to make sure to use a text editor that supports linux style line endings. I personally use Notepad++ but there other editors out there will also support these.
I recommend looking into VSCode Remote SSH. It allows you to use VScode on your Windows machine, then connect to and run code on Raspberry Pi. Worked quite well for me, that's how I primarily develop the Upgrade to Python 3 script.
I'll reply to both.
-
I did some investigation, and Linux terminates each line with a CR (carriage return), while Windows terminates a line with a CR/LF (carriage return/line feed pair). There is a preference setting in Notepad++ that controls this.
-
For any serious development on the Pi, I was intending to install Ubuntu on my big Windows machine using Hyper-V and do the development using that. Then copy the programs to the PI using Samba and run it there. I like using IDEs, so I'll stick with that. I did some minor C++ work on the Pi using Codeblocks. With the Pi 3, I can run their GUI and VNC server, and remotely work with the Pi from my big Windows machine. I might even try that using Ubuntu to work with the Pi.
Anyway, thanks for all the help. I learned a bit about Linux today.
1 Like