Use custom script to check if server is reachable

Tips and Tricks on AutomountMaker

Use custom script to check if server is reachable

Postby admin » Sat Nov 06, 2010 7:37 am

What's ?

This script is used when you select Ping server before trying to mount your volume under the Options panel.
Since version 1.3.4 it's possible to change the default ping script used by AutomountMaker for know if the host is reachable
or not before mount your volume.

Why change the default script ?

The default script is writing with Perl and some user (one for the moment, but...) tell me that my doesn't work fine !
So, I added this feature to resolve this problem.

Your script must follow these rules
have an argument -h
must be invoked as: -h
return "YES" if server is reachable or "NO"


This example is pre-installed into ./Contents/MacOS/, so you can use it without change it.
But you must set the hidden option (see How to install your new script)

Code: Select all
# name
# usage
# -h

args=`getopt h: $*`
if [ $? -ne 0 ]; then
  echo "Usage: $0 -h <yourhost>"
  exit 1

set -- $args
for o
do case "$o" in
 -h) shift; host="$1"; shift;;
 --) shift; break;;

ping -n -c 1 $host >/dev/null 2>&1
if [ $? -eq 0 ]; then
 echo -n 'OK';
 echo -n 'KO';

How to install your new script

    1) Quit AutomountMaker
    2) Select and choose Show Package Contents
    3) Open Contents/MacOS/ and copy your script on it,
    4) Open and enter this command (suppose that your script is called
    defaults write com.JMM.AutomountMaker AMScriptDictKey:PingScript
    5) Relaunch AutomountMaker
    1) Test your script before use it with AutomountMaker
    2) Check that the current user can launch this script
mac:MacOS user$ ls -l
-rwxr-xr-x 1 user admin 302 15 d?c 08:07

You can use default alternative script pre-installed into ./Contents/MacOS/ (see Example)
defaults write com.JMM.AutomountMaker AMScriptDictKey:PingScript
Site Admin
Posts: 14
Joined: Wed Nov 03, 2010 8:53 pm

Return to Tip and Trick

Who is online

Users browsing this forum: No registered users and 1 guest