Proper NSTask syntax in ASOC

Hello,

I’ve spent the better part of today trying to get a shell command to run from within my application but without stalling the UI while the script is executing. I’ve read (https://secure.macscripter.net/viewtopic.php?id=31541) that NSTask might be able to help me with this, but I’m having a hard time getting it to work.

I would like to replace this:

do shell script "cd " & pathToMePosix & " && ./" & videoPlugin & space & "\"" & romPath & "\""

with something like this:

			tell class NSTask of current application
				set arraylist to {"Users/john/Desktop/wonderful.sh"}
				set theTask to (NSTask's alloc)'s init()
				theTask's setLaunchPath_("/bin/sh/")
				theTask's setArguments_(arraylist)
				theTask's |launch|()
			end tell

where “wonderful.sh” would contain something like the above shell script. I can’t seem to get it to work, though. Can someone point me in the right direction?

Thank-you.

Model: MacBook Pro 13"
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)


set tool_path to POSIX path of ((path to desktop as Unicode text) & "say_hello.sh")
set theTask to current application'sNSTask's alloc()'s init()
theTask's setLaunchPath_("/bin/sh/")
theTask's setArguments_({tool_path})
theTask's |launch|()

My sincere thanks!

You are very welcome.

I am attempting to get this to work in an app I am writing, but no luck yet. Which authorization line should pop up the dialog window to ask for a user’s admin password? I’m trying to debug my app. I’m not getting the dialog.

The other difference is I am writing in Applescript ObjC so I am interpreting your code to my code so there might be a mis-type along the way also.