Stop Script after 10 Minutes

Hello,
I have a script that makes a connection with an external machine and exchanges data with it. The problem is that this external machine is not always on, and when that happens, my connection with the machine remains running until someone is at my machine to close it manually (which almost never happens). I was wondering if anyone knew of a way to tell my script to halt after a certain amount of time, say 10 minutes? Thanks!!

Hi Zach,

woudn’t it be easier to check, whether the external machine is on?

Well, the script is meant to be run by anyone who is told to run it, and there’s a good chance that they don’t know much about computers to verify whether or not the external machine is running.

There’s no need, that the people must have knowledge about computers :wink:
I meant, the script can check this

That would work too!!
Any idea how to incorporate something like that into a script?

Which kind of connection do you use?

Sorry I should have been more clear, it’s not exacly an external connection, but I’m trying to access a drive on the network we have. Here’s the part of the script where I try to access the drive:

mount volume "afp://Zach:1234@192.168.1.16/Corr Wet End HD"

Zach is my machine’s name, the IP is my IP on the local network, and Corr Went End HD is the drive I’m trying to access. At the end of the script, after I take the information from the drive I want, I tell Finder to eject the drive.

mount volume "afp://Zach:1234@192.168.1.16/Corr Wet End HD"

Edit: This is where the connection gets hung up. The AFP Connection program appears saying that it’s trying to connect, then after a few minutes a box pops up saying the connection couldn’t be made, but no one is around to click the OK button to terminate the attempted connectio between the machines.

I don’t have a second machine running to test this against but I used to use this:

with timeout of 60 seconds
	try
		get count of characters of (do shell script "ping -c 2 192.168.1.101")
		if result > 150 then set msg to "Answering pings"
	on error
		set msg to "The Laptop is Dead"
	end try
end timeout

If you want to check the IP addesses, cou can use this

property checkIP : "192.168.1.16"

tell application "System Events" to set servers to name of disk items of disk "Network" whose its file type is "slua"
set serverIPs to {}
repeat with i in servers
	set theIP to do shell script "arp -n " & i & ".local | cut -f 2 -d '(' | cut -f 1 -d ')'"
	if theIP is "" then
		set end of serverIPs to "not available"
	else
		set end of serverIPs to theIP
	end if
end repeat

if {checkIP} is in serverIPs then
	
	-- mount volume (if necessary) and do something
	
end if

but you can also check only the name of the server

property checkName : "Server Zach"

tell application "System Events" to set servers to name of disk items of disk "Network" whose its file type is "slua"
if {checkName} is in servers then
	
	-- mount volume (if necessary) and do something
	
end if

Excellent!! Thank you very much this is exactly what I’m looking for, and on such a fast reply!!!