now. press the button 3 second => safe shutdown => power down

I want to know how to executes this on rasp from software code like software x708off.