getting path

I’m trying to write a frontend in AS for the *nix command rsync. This command takes two arguments (at least for the use of rsync I want) a source, and a destination. Since rsync is a Terminal utility I have done the following:
tell application “Terminal”
activate
do script with command “rsync”
tell window 1
set title displays custom title to true
set custom title to “Benja0901’s rsync script”
end tell
end tell

now before this I want to get the source and destination. The best way (IMO) to do this would be to pull up a Path selection window (like you would see in a save as/open dialog) How do I spawn one of those windows, and capture the directory/file to a variable?

basically: source = resultOfOpenDialog1, dest = resultOfOpenDialog2. Then all I need to do is call rsync with: do script with command (rsync source dest)

set thePath to choose file
--> alias "Macintosh HD:Users:jed:Desktop:Picture 1.pdf"

j

Thanks, not quite what I want to do though (I think)…a temporary fix is to use dialog boxes to have user enter path. Since this is going to be used by someone with no idea of file structures, I would rather have a point ‘n’ click interface.

Question 2 that arises from this is how to pass these variables to the rsync command?
rsync -a src dest where src and dest are the variables, how can I pass them the value of the vars rather than the vars themselves (as *nix does not recognize src and dest, as, I expected, it is just parsing the command as plain text [do script with command])?

Thanks!

You say your users has no idea of file structures, but you want them to type a path rather than select it from a dialog?

Using choose file (or, probably even better, ‘choose folder’), you’re guaranteed to get a valid path on the disk (e.g. no typos, no folder that doesn’t really exist, etc., etc.)

That said, you can also use the ‘POSIX path’ command to convert the Mac-style alias record (as returned by choose file/folder) into a unix-style path. Additionally you can use ‘quoted form’ of this string to make it shell-safe (properly quoted/escaped for shell execution):


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Cam…
I could kiss the ground you walk on! This is exactly what I wanted. You are indeed right…I could have worded my second question better…I did want to use the choose folder dialog. the prompt to enter was a work-around until I could get the code I really wanted. PS: any good books you would recommend to someone looking to get into AS?