Skip navigation

Apple Script Help please

819 Views 5 Replies Latest reply: May 14, 2013 3:54 AM by Ry6001 RSS
Ry6001 Calculating status...
Currently Being Moderated
Sep 6, 2011 8:53 PM

Pleasewrite an AppleScript for the following scenario: You need to ping the address10.32.8.151 every 5 seconds and report to the current logged in user via adialog box and email a set address when the IP has failed to respond to morethen 6 pings or 30 seconds. Upon failure of the 6 ping test please have thescript run a trace route and export it to a file named tracereport.txt on~/Desktop

Xserve, Mac OS X (10.6.8)
  • Camelot Level 8 Level 8 (45,670 points)
    Currently Being Moderated
    Sep 6, 2011 11:24 PM (in response to Ry6001)

    This sounds remarkably like a homework assignment to me...


    I'm guessing something like this covers most of your points.


    property theAddress : ""

    global missedPings


    on run

              set missedPings to 0 -- initialize the counter

    end run


    on idle


                        do shell script "/sbin/ping -c 1 -t 1 " & theAddress

              on error

                        set missedPings to missedPings + 1

                        if missedPings = 6 then


                                  tell me to quit

                        end if

              end try

              return 5

    end idle


    on networkDown()

              do shell script "/usr/sbin/traceroute " & theAddress & " &> " & quoted form of POSIX path of ((path to desktop as text) & "tracereport.txt") & " &"

              do shell script "/bin/echo 'Network missed 6 pings' | /usr/bin/mail -s 'Network down'"

      display alert "Oops. Network failure" giving up after 5

    end networkDown

  • mcraig55 Level 1 Level 1 (20 points)
    Currently Being Moderated
    Sep 22, 2011 4:37 AM (in response to Camelot)

    Thanks, I got an A on the test.

  • Camelot Level 8 Level 8 (45,670 points)
    Currently Being Moderated
    Sep 22, 2011 9:21 AM (in response to mcraig55)



    Life lesson: next time, think it through yourself before passing the buck. That way the grade might count for something.


    Sure, there's something to be said for knowing when to ask for help, but having a stab at it first will serve you better in the long run.

  • Mike Pieronek Calculating status...
    Currently Being Moderated
    Apr 19, 2012 2:23 PM (in response to Camelot)

    Hey Camelot! This is great. I couldn't write this myself because I'm not very familiar with AppleScript. But I can alter your script a little to suit my needs. This is great.


    I've been trying to figure out a solution to a problem like this for days! Thanks!!!



    ( You were awfully nice to write the script in the first place, considering how it was asked for. )






More Like This

  • Retrieving data ...

Bookmarked By (1)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.