Waiting for last process

Ok so i’m making this application that requires a curl. Here’s what i got.

tell application "Terminal"
		activate
	end tell
	tell application "System Events"
		tell process "Terminal"
			keystroke "curl -O [url=http://www.gtlib.gatech.edu/pub/apache/httpd/httpd-2.2.9.tar.gz]http://www.gtlib.gatech.edu/pub/apache/httpd/httpd-2.2.9.tar.gz"[/url]
			keystroke return
			delay 10
			keystroke "gnutar -xzf httpd-2.2.9.tar.gz"
			keystroke return

The issue is to have the curl complete it’s process before proceeding. And also so that someone wouldn’t have to wait like 70 seconds. (delay 70) or something… So like after the download was done the next process would start, any ways for doing that?

Ok thanks it worked… Now how about a Sudo shell script?