Challenge: Call Method from AppleScript Studio application

Right here is the challenge. I need to run a command line tool inside my application - but it needs to be invisible to the user and be capable of running multiple commands in the same session, so that rules out ‘do shell script’.

I thought of using a Objective-C class that spawns a task to run a command, which is a binary located in my application’s bundle, which is fine, but I’m having issues calling the method from AppleScript. Does anyone have any experience with this sort of thing? The problem is that if you get it slightly wrong, syntaxically, it just doesn’t do anything - no error, no nothing. So I’m sort of at a loss on how I might track down whether the bug is in the Objective-C, the AppleScript method call or what…

Fingers crossed someone can help me?

Thanks
Ryan

Hi Ryan,

why shouldn’t a multi-command 'do shell script line work? Here an example:

set progs to POSIX path of (path to applications folder) & "Calculator.app"
set reslt to do shell script "open " & quoted form of progs & "; cd ~/Desktop/; curl -o 'thread.html' 'http://bbs.applescript.net/viewtopic.php?id=21621'; textutil -convert txt thread.html > thread.txt; cat thread.txt"

If this doesn’t help … why don’t you post the Obj-C code you have so we can see and tell you what’s wrong? :wink:

regards,

Dominik

Hey

The problem with the multi-line do shell script is that the first command was an SSH command, and therefore prompts for a password.

I have managed to solve the problem though so no need to panic!

Thanks
Ryan

Would you mind sharing?

Sure, what would you like to see? It was in the end caused by a bad line in the method call.