Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

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).

share|improve this answer
    
This does not provide me with the options that it is being run under, though. Is there a way to find this? –  Dave May 13 '13 at 18:57
    
Not as far as I know. There may be command line utilities included with Apple Remote Desktop that could do that, but I don't know one way or another. –  robmathers May 13 '13 at 19:18
    
Ya. I'm still looking for it. I wonder if AppleScript/Objective-C is the best route to take at this point. –  Dave May 14 '13 at 17:12
    
Although it doesn't solve OP's problem, this was useful for me - thank you! –  2rs2ts Jun 11 '13 at 21:48
add comment

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.

share|improve this answer
    
By "unreliable", do you mean that there are intermittent failures of the script? –  Dave Jun 11 '13 at 17:28
    
That's right: It will either tell you correctly whether or not Screen Sharing is running, or it will return an error. One other thing: the script says row 2, make sure row 2 is where your Screen Sharing is in the Sharing pane. –  Philip Kearns Jun 11 '13 at 20:20
    
@Dave I've updated the code so it's clearer –  Philip Kearns Jun 11 '13 at 21:48
    
Thanks. My experience is that there is a general issue with OS X's new security model and AppleScript. Depending on conditions outside of the Terminal environment, an AppleScript may or may not run correctly, falsely complaining about syntax errors and whatnot. Poor release engineering on Apple's part and I still haven't found a solution. –  Dave Jun 13 '13 at 21:00
    
Going back to the main issue, though, I'm looking more for a way to determine not just that it is running, but what configuration it is running with. Thanks for your AppleScript example, however, it might provide a lead. –  Dave Jun 13 '13 at 21:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.