Mount Drive based on connection with if else statement (applescript) can someone please help me out with this script.  Where am I going wrong?
Try
set ping to (do shell script &quot;ping -c 2 &quot; 192.168.1.240)

if ping contains &quot;64 bytes&quot; then
tell application &quot;Path Finder&quot;
    try
        mount volume &quot;smb://192.168.1.240/home&quot;
        mount volume &quot;smb://192.168.1.240/shared&quot;
        mount volume &quot;smb://192.168.1.240/video&quot;
        mount volume &quot;smb://192.168.1.240/music&quot;

Display Dialog &quot;Mapped Drives to 192.168.1.240 Network.&quot;

Else
tell application &quot;Path Finder&quot;
    try
        mount volume &quot;smb://192.168.0.240/home&quot;
        mount volume &quot;smb://192.168.0.240/shared&quot;
        mount volume &quot;smb://192.168.0.240/video&quot;
        mount volume &quot;smb://192.168.0.240/music&quot;

Display Dialog &quot;Mapped Drives to 192.168.1.240 Network.&quot;
Your set ping to statement should have the closing quote after the IP address

In general you are missing a number of end statements. Each try should have a corresponding end try, each tell should have an end tell, each if should have an end if.

The try statements should surround the script action, not inside them. So move them before the tell 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 &quot;Finder&quot;


Here's a briefer example:
try
    set ping to (do shell script &quot;ping -c 2 192.168.1.240&quot;)
    
    if ping contains &quot;64 bytes&quot; then
        try
            tell application &quot;Finder&quot;
                mount volume &quot;smb://192.168.1.240./music&quot;
            end tell
        end try
        display dialog &quot;Mapped Drives to 192.168.1.240 Network.&quot;
        
    else
        try
            tell application &quot;Finder&quot;
                mount volume &quot;smb://192.168.0.240./music&quot;
            end tell
        end try 
        display dialog &quot;Mapped Drives to 192.168.0.240 Network.&quot;
        
    end if
end try