why is this not working…
set the result to display dialog “Enter the Server Name (or IP)” default answer “” buttons {“OK”, “Cancel”} default button 1
set server to text returned of result
tell application “Finder”
try
set ping_result to (do shell script "ping -c 1 -q " & server)
if “100% packet loss” is not in ping_result then
mount volume “ftp://” & server as user name “tester” with password “test”
end if
on error
set host_name to do shell script “ls /Network/”
end try
end tell
Where is it not working? What’s the event log look like?
Your ping command works on this end, so perhaps it is how you search for the success or failure that is not working?
I have a routine for the same purpose, but I use grep to filter the result like this:
on testServerConnection()
-- ping the print file server to see if it exists on the server
set theCommand to "ping -c 1 192.168.1.210 | grep 'packets received'"
set theResults to do shell script (theCommand)
-- now parse the results of the ping
set AppleScript's text item delimiters to ", "
set theTest to second text item of theResults
set theNumber to first word of theTest
if theNumber is "1" then
return true
else
return false
end if
end testServerConnection
If a packet is recieved a 1 is returned by the ping command, otherwise 0 is returned. By searching for this I verify is success.
Hope this helps,
jON bEEBE