Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

Apple Script

Dear all,

I am looking for a script that would run in the background pinging this address 192.168.1.2 and when the ping gets a response i want it to mount two afp drives.

Would this be possible?

The script would run in the background?

Regards

Lyon JT
0
LyonJay
Asked:
LyonJay
1 Solution
 
LyonJayAuthor Commented:
Thank you!

Much apprieated!

Regards

LyonJT
0
 
slyongCommented:
Hi Lyon,

What you want to do is easily achievable in shell script.  Using AppleScript to run in background, etc is a bit tedious.  Anyhow, I have written a short AppleScript that "almost" do what you need and you may tweak it a bit more:

repeat
      tell application "Finder"
            try
                  set ping_result to (do shell script "ping -c 1 192.168.1.2 | tail -1")
                  if "100% packet loss" is not in ping_result then
                        mount volume "afp://192.168.1.2/mountpoint" as user name "username" with password "password"
                  end if
            end try
      end tell
end repeat


A simpler suggestion is using shell script:

#!/bin/sh
ping -o 10.2.126.55 >/dev/null
osascript -e 'try' -e 'mount volume "afp://username:password@192.168.1.2/mountpoint"' -e 'end try'
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now