Applescript, how to mount remote server without error if unavailable?
Using a macOS Catalina system as the file server with /Users/Shared/Videos as an SMB shared resource, and having done a bit of testing, found the following example AppleScript code to work well when testing using Script Editor from another system on the network in which the credentials have already been saved in its Keychain:

set ipAddress to "172.16.15.141"
set sharedResource to "Videos"

if workgroupAvailable(ipAddress) then
    mount volume "smb://" &amp; ipAddress &amp; "/" &amp; sharedResource
end if

on workgroupAvailable(ipAddress)
    set workGroup to do shell script ¬
        "smbutil status " &amp; ipAddress &amp; " | awk '/Workgroup:/{print $2}'"
    if workGroup is equal to "" then
        return false
    else
        return true
    end if
end workgroupAvailable




The replies from the above example AppleScript code were:

When the shared resource was not available:

 tell current application
    do shell script "smbutil status 172.16.15.141 | awk '/Workgroup:/{print $2}'"
    --&gt; ""
 end tell


When the shared resource was available:

tell current application
    do shell script "smbutil status 172.16.15.141 | awk '/Workgroup:/{print $2}'"
        --&gt; "WORKGROUP"
end tell
tell application "Script Editor"
    mount volume "smb://172.16.15.141/Videos"
        --&gt; file "Videos:"
end tell
Result:
file "Videos:"




What I found with using the smbutil status command over curl, which on my network required httpd running on the server, and ping, which could reply even if the shared resource wasn't available, was that smbutil status failed to return the Workgroup name if the shared resource wasn't available to be mounted and in turn no attempt to mount occurs if the Workgroup isn't available.

This example AppleScript code also did not cause any dialog boxes to appear at any point when the shared resource wasn't available.

Note that although testing was done with the rebooting of the file server and attempting to connect at various times during the reboot and the system actually being available, I was unable to test if the system had hung during the reboot, as it just has never hung during any reboots. As I know this is an unresolved issue with the rebooting of your server, you can give this a try if you so choose. 

Obviously you can adapt the example AppleScript code to suite your specific needs.



Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.