Mount Drive based on connection with if else statement (applescript)
Solution 1:
-
Your
set ping to
statement should have the closing quote after the IP address -
In general you are missing a number of
end
statements. Eachtry
should have a correspondingend try
, eachtell
should have anend tell
, eachif
should have anend if
. -
The
try
statements should surround the script action, not inside them. So move them before thetell
statements. As you are using them without the 'on error' clause, the try statements aren't very useful - but no harm. -
The application should be just "Finder"
Here's a briefer example:
try
set ping to (do shell script "ping -c 2 192.168.1.240")
if ping contains "64 bytes" then
try
tell application "Finder"
mount volume "smb://192.168.1.240./music"
end tell
end try
display dialog "Mapped Drives to 192.168.1.240 Network."
else
try
tell application "Finder"
mount volume "smb://192.168.0.240./music"
end tell
end try
display dialog "Mapped Drives to 192.168.0.240 Network."
end if
end try