Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arkestra

macrumors newbie
Original poster
Jun 10, 2012
3
1
Hello,

I'm trying to write an applescript to connect automatically to my NAS over AFP on my local network, or over FTP if I'm outside.

I'm a beginner with Applescript, and I tried that:

tell application "Finder"
try
mount volume "afp://XXX:XXX@192.168.X.X/VOLUME"
end try
else
mount volume "ftp://XXX:XXX@xxxx.dscloud.me/VOLUME"
end tell​

I would like the script to check connection with AFP, and if the connection cannot be set, to try a connection with FTP. And if it cannot connect, to do nothing (not even an error message).

Is it possible?

Thank you,

Mathieu
 
Try this

Code:
if (do shell script "ping -c1 000.000.0.000") contains "1 packets received" then
	try
		if (list disks) does not contain "SHARE" then
			mount volume "afp://000.000.0.000/SHARE"
		end if
	end try
end if
on quit
	continue quit
end quit

Replace 0's with your server IP, and SHARE with your share name.
 
Last edited by a moderator:
Code:
if (do shell script "ping -c1 000.000.0.000") contains "1 packets received" then
	try
		if (list disks) does not contain "SHARE" then
			mount volume "afp://000.000.0.000/SHARE"
		end if
	end try
end if
on quit
	continue quit
end quit

Replace 0's with your server IP, and SHARE with your share name.

this works but how do I make it reloop all the time?
when the connection to a share is broken i would like to reconnect.
Doesn't it have to reloop this script with an interval of say 10 seconds?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.