Automator - Monitor network share and quit..

Discussion in 'Mac Programming' started by philstone, Feb 28, 2017.

  1. philstone macrumors 6502

    Joined:
    Oct 13, 2008
    Location:
    Jersey, Channel Isles
    #1
    Hi all,

    Does anyone know if its possible to create a workflow/package that monitors connectivity to a networked folder and if the connection breaks, either displays a warning message, or quits a specific application?

    I have a program that depends on connectivity to a share, however the program doesn't do anything if the connection breaks.. :(

    Cheers
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    The basics of an AppleScript based solution would be something like this:

    Code:
    on idle
       if (list disks) does not contain "Your Share Name Goes Here" then
           activate
           display dialog "Where is it?" buttons {"OK"} giving up after 5
       end if
    end idle
    

    ...save it as a stay open applet.

    Whenever the Mac is idle, the app will pop up the warning if a share with the name you define is not in the list of mounted shares. It's only intended to be a snippet to get you started - you'll probably want to finesse it somewhat!

    Its a bit of a clunky solution. There are probably slicker ways, but it should work.

    Good luck
     
  3. philstone thread starter macrumors 6502

    Joined:
    Oct 13, 2008
    Location:
    Jersey, Channel Isles
    #3
    Brilliant, thanks for the start!

    I'm assuming 5 = seconds?
     
  4. philstone thread starter macrumors 6502

    Joined:
    Oct 13, 2008
    Location:
    Jersey, Channel Isles
    #5
    Thanks, I only want this to run when the application that depends on the share is running.

    Thinking about it, thats not really going to be possible without having it running constantly and first of all performing a check for whether the application is open or not. How much of a resource drain would this have? Negligible?

    Thanks
     
  5. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #6
    You can get the name of running apps like this:

    Code:
    tell application "System Events"
       set theRunningApps to name of every process
    end tell
    
     

Share This Page