Command-Line Tool?

Ok, I think this is kinda an odd question. I posted it in the Applescript Studio board because I think it requires Xcode. I would like to take a normal applescript that I have written, and run it from the command line, but it requires user interaction, so I can’t use osascript. Is there a way to compile an applescript so that it runs in the terminal, like you can do with C++ if you select “File>New Project>Command Line Utility>C++ Tool”?

Try saving the script as a run-only application (no startup screen) and use this code either in Terminal, or as a do shell script:

open ~/Desktop/

If you use the do shell script, I think you need to send the full path of the script, and not use the tilde.

So is that the only way to do it? I was hoping there would be a way to interact with it from the command line itself. :expressionless: Thanks for the suggestion, though. :slight_smile:

What do you mean by interacting with it from the command line? What sort of interaction does the script require?

I’m fairly certain it’s not possible, but I was hoping it could, for example, accept some text, manipulate it, and output the result (which I already have working with "display dialog"s). I wanted to be able to do it so that the script could be used from other platforms via SSH/Telnet. I know that sounds stupid. But thanks for the tips.

How would you “accept some text” if you are calling the script from the shell?

Umm… that’s sorta the question.

Don’t worry about it though, I’ve pretty much given up. Thanks for the help.

By “accept some text” I think he means that the terminal would issue a prompt for user input.
I think what he wants to do is have a utility that can be accessed by SSH. Upon connection and running the app, the user, viewing a terminal screen on their local machine, but connected to this app on a remote machine would be presented with a prompt to enter a username, or the name of a task to preform, or a parameter needed to preform a function… etc…

Dr. Scotty Delicious, Scientist.

EXACTLY! Thank you for clarifying that so articulately. I definitely couldn’t have said it better ;). As I don’t think that’s possible, though, if somebody has any suggestions for controlling a script running on my mac from another computer running a non-mac OS, that would be wonderful, and greatly appreciated.

So the script would prompt you? Could you also pass some text as a parameter? (Text could also be read from a file or stdin, but it’s sounds like you’re not looking for that.)

Here’s an osascript example.


on run {userInput}
    return "AppleScript result: " & userInput
end run

Using osascript:

/usr/bin/osascript /path/to/test.scpt "Hello World"


OK; thanks Bruce, that’s great. I guess there’s not anyway to give the user prompts to enter information during execution (i mean like in the middle of the script) though, is there?

You can try playing with ash (an AppleScript shell written in Perl). If you’re running it on an Intel machine, check out the end of this article:

OK thanks. Ash looks like it could be pretty good. I have a few major assignments to work on now, but I’ll be sure to test it on the weekend.