Re: applescript "ping"
Re: applescript "ping"
- Subject: Re: applescript "ping"
- From: Adam Bell <email@hidden>
- Date: Fri, 03 Nov 2006 18:37:37 -0400
Title: Re: applescript
"ping"
At 12:35 PM -0500 11/3/06, Bob Cuilla wrote:
I have a Mac network with several
machines that are all being backed up, from a server, by Retrospect.
The automatic backup runs Retrospect scripts for each machine.
Most of the time some of these machines are out of the office
(laptops) and of course, Retrospect cant find them. In this case
Retrospect issues a warning.
I would like to check for the presence of these machines, maybe a
ping. The result would allow me to script Retrospect
accordingly.
In other words, is a particular machine is not on the network, I would
not try to back it up.
Does anyone have any ideas on this
issue?
I use
this:
set tid to AppleScript's text item delimiters
set myIP to getInternalIP()
if myIP is " unknown " then
display dialog "You do
not seem to be connected"
return
end if
set AppleScript's text item delimiters to
"."
set subNet to text items 1 thru 3 of
myIP as text
set MM to text item -1 of myIP as text
set AppleScript's text item delimiters to tid
set P to (do shell script "ping -c3 " &
subNet & ".255")
set AppleScript's text item delimiters to return &
"64 bytes from " & subNet & "."
set Nup to text items 2 thru -1 of P
set IPisUp to {}
set AppleScript's text item delimiters to
":"
repeat with aLine in Nup
tell
(text item 1 of contents of aLine) to if it is
not MM and it is not in IPisUp then set end of
IPisUp to it
end repeat
set AppleScript's text item delimiters to tid
set tellMe to "The following IP's (excluding this
machine, " & myIP & ") are now answering broadcast
pings on your subnet." & return & return
repeat with anIP in IPisUp
set tellMe to tellMe &
subNet & "." & contents of anIP &
return
end repeat
display dialog tellMe with icon 1
(*Note: SP2 for WinXP automatically disables answering broadcast
pings unless the instruction "set multicastbroadcastresponse
ENABLE" is entered in each by an administrator of the
machine.*)
to getInternalIP()
set
the_interface to 0
repeat
set ip_internal to ""
try
set ip_internal to do shell script
("ipconfig getifaddr en" & the_interface)
end try
if ip_internal is not "" then exit
repeat
set the_interface to the_interface + 1
if the_interface = 5 then
set ip_internal to " unknown "
exit repeat
end if
end repeat
return
ip_internal
end getInternalIP
Adam Bell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden