Tell application "Finder"
do shell script "/sbin/ping -c 1 [url=http://www.bowdoin.edu]www.bowdoin.edu[/url] | /usr/bin/grep ret=-1"
set pingresult to result
display dialog pingresult
end tell
[quote]
Could someone tell me why I get a type 1 error when I run this?
Thank You
[/quote]
Does it work from the command line? Does it work if you take the Finder out of the script (I don’t see anything that requires the Finder).
do shell script "/sbin/ping -c 1 [url=http://www.bowdoin.edu]www.bowdoin.edu[/url] | /usr/bin/grep ret=-1"
set pingresult to result
display dialog pingresult
playing with it here, it appears as though the problem is that if the ping works there is no output from the command.
More specifically, the grep is filtering out all the lines, so nothing gets passed back to the script.
Instead, try something like:
set pingResult to do shell script “/sbin/ping -c 1 www.bowdoin.edu”
if pingResult contains “ret” then
– oops. host is down
end if
In this way you’re passing the entire result of the ping back into AppleScript, and using AppleScript to parse the result for the string you’re looking for.