Check Remote Management Status via Terminal
I need to be able to SSH into a Mac (Mountain Lion) and check if ARD is running and if so, what are the settings. Basically, I need the equivalent of going to System Preferences -> Sharing -> Remote Management and visually inspecting the options set there. But I need it on the Terminal so I can do this via SSH.
Note, I am not asking how to set these options (e.g. through the ARD "kickstart" executable), I am asking how, once it is running, to determine what options it is running under.
ps -axlww | grep ARD
shows only /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent
without any flags shown.
Is there a plist file where this is stored? So far I've checked ...
/Library/Preferences/com.apple.ARDAgent.plist
/Library/Preferences/com.apple.RemoteManagement.plist
... and similar files within the user's ~/Library/Preferences/
directory, and they do not seem to contain anything useful.
You can tell if it's enabled by running launchctl list | grep '^\d.*RemoteDesktop.*'
. That will output a line if there's an active process for the RemoteDesktop
agent, and will output nothing if not. There's an active process for the agent whenever Remote Management is enabled, even if there's no active connection (unlike something like Screen Sharing, where the process is only active when there's a connection made).
I have a possible solution for you, I say 'possible' because it's not very reliable (I submitted a question on it earlier).
One other thing, you'll have to "Enable access for assistive devices", I don't know why. So here's the AppleScript:
tell application "System Preferences"
reveal pane "com.apple.preferences.sharing"
end tell
tell application "System Events"
set SSCBrow to 2 -- Set to the row corresponding to Screen Sharing
tell process "System Preferences"
set screen_sharing_toggle to value of (checkbox 1 of row SSCBrow of table 1 of scroll area 1 of group 1 of window 1) as boolean
end tell
end tell
tell application "System Preferences"
Quit
end tell
set newvar to screen_sharing_toggle
If you save that as, say, checkScrShr
you can run it from the command line as:
osascript checkScrShr
It will echo 'true' if Screen Sharing is enabled, 'false' if it isn't.