Remote Shutdown of MacOS
BurbankAV
Posts: 4
Does anyone have good suggestions for doing remote shutdown of Mac CPU's? I do this all the time with Windows-based machines (using i!-ConnectLinx), but I haven't found a thread about doing this with a Mac-OS CPU. (And for all you Bootcamp/Parallels/etc folks: sorry, this needs to be MacOS...)
I'm open to any suggestions! Thanks, all!
I'm open to any suggestions! Thanks, all!
0
Comments
Manually or automated?
http://www.youtube.com/watch?v=Eupb9vbvQPQ&feature=related
A bit complicated but I can't find anything better.
Jorde_V --> I'm not sure what you mean: I just need an AMX controller to be able to shutdown a Mac Mini. Whether it's at a scheduled time, or on a button push doesn't seem (to me) to be an issue. Is there an element to this that I'm missing that would make this distinction important?
Avargas --> Thanks for the good idea. Unfortunately, I'm on a (very) closed system, so email is out of the question, but the idea of using Applescript is a good one. Is there a way to remotely trigger an Applescript? I'll poke around on some of the Mac guru forums, but if anyone knows a good way, I'm all ears!
pdavis41 --> This sounds cool and very useful. Could this be used to trigger an Applescript (as above)? That opens up a world of possibilities. (Would you be willing to share your script with the forum?)
Thanks, everyone! I'm open to all ideas, and I'll let you know what I find!
#!/bin/bash
listenPort=9
pckt_shutdown="shutdown"
echo "Started"
while `true`
do
pckt_data=`nc -l ${listenPort}`
if $? != 0
then
echo "nc returned error."
exit 1
fi
if "$pckt_data" == "$pckt_shutdown"
then
echo "Matched! Received shutdown packet, now shutting down..."
shutdown -h -u now
exit 0
fi
done
save it as a shell script and run it from a command line. You have to run it as sudo <script_name> though so it has root privileges. I'm still trying to figure out how to get it to run at startup though.
Well... this is a lot easier than all the above... This is basically a unix machine.
Make sure the telnet daemon is enabled. Which you can do in a terminal window...
and... open a TCPIP connection to Port 23 on the mac machine and send the follow commands....
// raw data
//netlinx code
Was going to suggest you don't need to do it remotely if you want to schedule it.
Remotely you can use the 'shutdown' command, and you can actually let it boot up again using that command as well. (With the -R command) You can ssh/telnet in to the machine to do it. Jeff's solution basically. (A google on 'remote shutdown mac' would've done the trick)
If you send a shutdown command to a mac. it will NOT wake up with WoL. It will only respond to a WoL command if it is in a sleep mode.
Doesn't do me a whole lot of good when the museum wants them off for that whole being green thing.
It consumes a watt in sleep state.
I've found this too. I have a system that controls 30+ macs and at end of day I have the system reboot them (to give them a reset basically) and then put them to sleep.
The firm that wrote the media software running on the macs also wrote a control interface which I don't have access to I'm afraid.
I find "this whole green thing" to be unbelievably annoying. The amount of power you waste leaving a Mac in sleep mode rather than full shutdown could probably be offset by turning one set of lights off a half hour early every day. People are absolutely rabid about tiny, miniscule savings, and utterly ignore the big issues that actually matter. You ever look at the impact of a single commercial airline flight compared to that of a car? Yet we go nuts squeezing every possible MPG out of an automobile, and how many airlines are replacing their fleets with more efficient planes?
We are holding ourselves hostage to "feel good" measures that make people think they are doing some good. We need to be actually doing things that make a difference, not catering to political correctness.
I just find it annoying that a PC will wake from a off state with WoL and a Mac won't.
Back to the topic on hand, I HATE having to do a login routine on telnet connections. Has anyone come across a way to make a telnet server on a mac unprotected? Security isn't a issue with the ones I'm controlling.
The mac is running OS X 10.6.8
When I open the port to 23 of the macs ip I get back FF,FD,18,FF,FD,20,FF,FD,23,FF,FD,27,FF,FD,24.
From what I have seen tooling around here it is the telnet negotiation. No luck on responding to it though with anything that anyone has posted before.
Any thoughts?
It's been a while since I wrote a module for telnet negotiation, but I seem to remember that it involves the two ends challenging each other to see what features they each support. Basically it boils down to the host you're connecting to making two types of statements:
- Do <something> (ie. you implement this feature)
- I Will <something> (ie. I'm going to implement this feature)
All you need to do is send the appropriate response for "I won't" <do that> ($FC) and "don't" <do that> ($FE) respectively and no options will ever be implemented. As a result you get left with a plain text connection. Pretty simple stuff.
* DO (x): decline with IAC WONT (x)
* We don't know how to do that.
* WILL (x): ask them not to with IAC DONT (x)
* I don't know what you're talking about, so we'll ask you not to.
My module acts as an interface to a socket connection and you just pass comms through it. Unfortunately I can't give it to you as it's not my IP to hand out
However, the RFC for telnet is pretty straightforward, you just need to parse out any interpret as command responses (= $FF) and then look for either of the opcodes above (DO = $FD, WILL = $FB) following. The next byte is the option they want to implement.
The first sequence in the above is "$FF,$FD,$18" = "'Interpret as command', DO, 'something' (who cares what, we're not going to implement it)".
The response would be "$FF,$FC,$18" (hex obviously) = "'Interpret as command', WON'T, 'whatever it was you asked me to do'".
http://www.amxforums.com/showthread.php?6856-TELNET-commands&highlight=Telnet+session
Hi Everyone,
Designing a system for a museum, need to have AMX shutdown a bunch of Mac mini's that drive the various exhibits, wanted to revisit this topic and see if anyone has any updates or additional suggestions as to what works, preferably reliably and consistently!
Think I have the boot thing covered - I've specified SurgeX iControl IP controllable outlet strips, which will allow the Macs to be booted/rebooted from full powered off or locked up states, by setting them to Auto Restart from AC Power loss. (As I understand it, Wake on Lan protocol works from some variation of a sleep state only, as the computers Network interface needs to be powered to allow it to respond to the Wake)
Obviously, don't want to just yank the power to shut them down and corrupt data, need to trigger an orderly shutdown from AMX. As I undertstand it, and has been mentioned previously, know shutdown can be triggered from an SSH connection such as Apple Desktop Server, but I don't know if AMX can initiate SSH communications, or what other issues and considerations need to be taken into account.
I've been programming AMX systems since the mid 90's, but my background is really AV, not hardcore programming, and while I'm good at parsing RS232 strings, etc, I'm still getting my feet wet w/ IP based control.
Appreciate anyone who can share some wisdom &/or suggestions. Thanks so much!
You should call and ask around AMX HQ. There are a couple guys there that programmed the system that controls all of the Apple Stores, and they should be able to give you some help.
Your AMX rep might know somebody to contact to get you in touch with the right people too.
Just my 2-bits worth. All the best with it.
Roger McLean.
For you situation an alternative that may be worth investigating is rolling a little utility app that runs on the exhibit machines. As having the machines operational is a I'm guessing a rather important aspect of the system this will allow you to not only expose an API for power control but also some basic monitoring. For security you can then lock this to only accept a socket connection from your NetLinx box that interfaces with it.