I'm trying to make a simple program that will give a user a GUI for running the Ditto terminal command but I have run into a snag. I allow the user to select their own paths and then the variables for those paths go into a shell script that will run ditto with admin privileges.
The code I'm posting is mostly irrelevant but it will be necessary for context:
on startDitto_(sender)
try
set dialogResult to display dialog ¬
"Are you ready to start copying files?" buttons {"Cancel", "Yes"} ¬
default button "Yes" cancel button ¬
"Cancel" giving up after 15
on error number -128
set userCanceled to true
end try
try
if userCanceled then
display dialog "User Cancelled"
else if gave up of dialogResult then
display dialog "Timed out"
else if button returned of dialogResult is "Yes" then
do shell script "ditto -V " & sourceFolder & " " & destFolder with administrator privileges
end if
end try
end
The issue lies here:
else if button returned of dialogResult is "Yes" then
do shell script "ditto -V " & sourceFolder & " " & destFolder with administrator privileges
end if
Everything works great up until you hit "Yes." It doesn't continue, doesn't ask for a password, just sits. I have read a bit on embedding a script but that doesn't necessarily work since I'm using variables in the script (unless the script can use those variables but when I embedded a script.sh it didn't seem to work) and then I was lead to NSTask but I'm not well versed in Objective-C or Cocoa yet.