Author Topic: Full power-off from software  (Read 551 times)

jimb137

  • Newbie
  • *
  • Posts: 4
Full power-off from software
« on: March 04, 2018, 06:47:34 PM »
Hi,  ATXRaspi is great... does everything you said it would...  However...

The short script on the second page of the above subject is wrong.  It aliases two commands (atxshutdown and atxreboot) to a script named shutdown.  This should refer to softshutdown.sh.  minor error, but still a glitch.

The diagram on page 1 of this section refers to a 2N3904 NPN transistor.  Not having one of those laying around, I used a BC546BTA and it works just fine.  I guess just about any NPN will work as long as it can handle 5V.

Lastly, a shortcut.  Many folks don't know you don't have to type the word 'source' to execute a shell script in the current shell (yea, that's what it does).  I use the shorthand version.

You would write :  source /usr/bin/foo.bar
I would write:       . /usr/bin/foo.bar

Thus saving 5 letters I don't have to type.  Over a lifetime, that may add up to the book I'm never gonna write  :^)

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6018
  • Country: us
    • LowPowerLab
Re: Full power-off from software
« Reply #1 on: March 05, 2018, 12:39:59 PM »
Hi jimb137,
Thanks for your message and feedback,

The short script on the second page of the above subject is wrong.  It aliases two commands (atxshutdown and atxreboot) to a script named shutdown.  This should refer to softshutdown.sh.  minor error, but still a glitch.
I'm not sure where exactly you are referring to. But the page you mention has this content, which includes the .sh terminations:


The diagram on page 1 of this section refers to a 2N3904 NPN transistor.  Not having one of those laying around, I used a BC546BTA and it works just fine.  I guess just about any NPN will work as long as it can handle 5V.
You are correct about the diagram. The paragraph above mentions a "NPN transistor" suggesting any would work, but I will add to it to make it even more obvious.

Lastly, a shortcut.  Many folks don't know you don't have to type the word 'source' to execute a shell script in the current shell (yea, that's what it does).  I use the shorthand version.
You would write :  source /usr/bin/foo.bar
I would write:       . /usr/bin/foo.bar
Makes sense, but it was done for transparency/completeness.
The first 2 lines are much longer to type, you can copy-paste the lines in the terminal depending which one you use.

jimb137

  • Newbie
  • *
  • Posts: 4
Re: Full power-off from software
« Reply #2 on: March 07, 2018, 11:15:56 AM »
In my first attempt to define the problem I should have made my self clearer.

Your script reads as follows:
$ printf "%s\n" "alias atxshutdown='sudo shutdown.sh'" >> ~/.bashrc
$ printf "%s\n" "alias atxreboot='sudo shutdown.sh 1'" >> ~/.bashrc
$ source ~/.bashrc

What I was trying to indicate was that the scripts named in the aliases were wrong.  They should read:
$ printf "%s\n" "alias atxshutdown='sudo softshutdown.sh'" >> ~/.bashrc
$ printf "%s\n" "alias atxreboot='sudo softshutdown.sh 1'" >> ~/.bashrc
$ source ~/.bashrc

Hopefully that's clearer.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6018
  • Country: us
    • LowPowerLab
Re: Full power-off from software
« Reply #3 on: March 07, 2018, 11:30:02 AM »
Ah, you are completely correct, when you typed shutdown without the .sh I interpreted that as missing the termination.
It is now corrected.
Thank you!