Solving launchctl load “nothing found to load” error

Today I was playing with OSX launchctl command, in order to autoload a program using a simple and human-readable XML file (.plist).
Initially my command (sudo launchctl load /path/to/myplist.plist) was giving back an error message “nothing found to load” and I thought it was a bad configuration in the plist, so I checked every path and every settings I specified in it and I realized it was ok… so using the manual (man launchctl) I looked for helpful flags and/or additional help, I then modified the command adding the -F and -w flags and I was able to run my program succesfully. It also started up automatically after a reboot as I wished.
The final command is:

sudo launchctl load -w -F /path/to/myplist.plist

Flags descriptions are the following:

-w Overrides the Disabled key and sets it to false. In previous versions, this option would modify the configuration file. Now the state of the Disabled key is stored elsewhere on-disk.

-F Force the loading of the plist. Ignore the Disabled key.

Learning shell scripting while trying to fix Snow Leopard local network issue :)

Mac OS X is a great system, but this doesn’t mean it’s perfect and without issues. One thing is not working as it would (in Snow Leopard 10.6.X), it’s the automatic discovering and mounting of local machines connected to the same network. This is especially true if the network includes a lot of Windows computers. Theoretically those machines should be automatically discovered and displayed in Finder under “SHARED” label, but often this is not the case. Anyway in such cases is fortunately possible to connect to a particular device from Finder (once we know its IP address) by choosing “Connect to server…” (cmd+K) and by using the Samba protocol (ie: smb://ip-address). This is however very annoying, because we have to know each ip we want to connect to and type several addresses, so I spent some time to find a way to make this process automatic (because I didn’t find a solution to the original OS X issue) and I realized a shell script which tries to do the job the Leopard should do :)
I’m really a newbie when it comes to shell scripting (and networking too :P) and my script doesn’t work perfectly, anyway it does an acceptable work the most of times and although it doesn’t really solve the problem, it could help a lot.
The script is the following:


# get user name
declare currentuser=$(whoami)

# get mac name
declare macname=$(scutil --get ComputerName)

# save arp command result
declare ipstring=$(arp -a)

# split ipstring into an array by using a regex to match ip addresses
declare -a iplist=($(echo $ipstring | grep -o -E "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})"))

# display addresses found
echo "${#iplist[*]} ip addresses found"

# switch directory to user dir
cd /Users/$currentuser

# for each ip in list try to mount it using smbfs
for ip in ${iplist[@]}
if [ ! -d link-to-$ip ]
echo "creating directory link-to-$ip under /Users/$currentuser"
mkdir link-to-$ip
echo "trying to mount //$macname:@$ip/Public"
mount -t smbfs //$macname:@$ip/Public /Users/$currentuser/link-to-$ip
echo 'folder "link-to-$ip" already exists... skip'

# complete
exit 0

Any comment and suggestion is really appreciated! Thanks