Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mrkapqa

macrumors 6502
Original poster
Jan 7, 2012
441
75
Italy, Bolzano/Bozen
Hello ,

i do use several Raspberry Pi, Rock64 Mini Computer for hobby and learning and found that the Samba File Sharing on the Mac does a bit struggle when trying to serve different computer probably.

Have setup on a MacMini 09 Server running 10.6.8 several Folders for "File Sharing" using "AFP" "FTP" "SMB"
accessing those folders from the Raspberry functions always with "FTP" and less so with "SMB"

what i found out is that whenever i would restart the File Sharing service, eg. by unticking "File Sharing" and then reloading it by ticking it in the Preferences / Sharing / section, the "SMB" shared folders would show up on the Single Board Computer and be accessible in say Kodi or Libreelec.


My question is how could i restart those service eg. automate the process of unloading/restarting the File Sharing Service at intervals?
 

Wowfunhappy

macrumors 68000
Mar 12, 2019
1,618
1,992
Have you considered writing an Applescript to click the checkmark in System Preferences? This works for me in OS X 10.9, wrote just now in five minutes! ?

AppleScript:
tell application "System Events"
    tell application "System Preferences"
        set current pane to pane id "com.apple.preferences.sharing"
        activate
    end tell
    tell application process "System Preferences"
        tell window "Sharing"
            tell group 1 to tell scroll area 1 to tell table 1 to tell row 3 to tell first checkbox
                click
            end tell
        end tell
    end tell
end tell

The primary thing I suspect may need adjustment in Snow Leopard is the line tell group 1 to tell scroll area 1 to tell table 1 to tell row 3 to tell first checkbox, because I can't remember if Snow Leopard's preference pane is laid out the same way. For instance, if "File Sharing" is not the third item in the list, you'd want to change tell row 3 to whatever the correct row is.

Telling window "Sharing" to get entire contents is helpful to see what's available.

You could also tell the System Preferences app to close at the end of the script, if the open window annoys you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.