call on open from terminal

Hi all!

Being a newbie here, this question may have been asked before. I did try to search the using “terminal on open” but none of them look like what am I looking for.

Is it possible to call Applescript “on open” function from terminal? Thanks in advance.

I’m not exactly sure what you’re asking. It sounds to me that you’d like to invoke an AppleScript when the Terminal.app first starts up?

It’s possible to invoke a shell command when a Terminal window opens up†, and that shell command could invoke an AppleScript (via osascript). And if you want to get fancy, that AppleScript or shell command could check to see how many shells are currently running (e.g. via ps), and if there’s more than one, it could assume that the Terminal did not just startup.

Hope this helps.


† You can invoke a startup script either through the Terminal preferences or via your selected shell’s preference file(s). For example, see the INVOCATION section of man bash

Thanks for reply.

Sorry for the confusion. I was trying to launch an Applescript with argument.

I have found the answer to my question. According to developer.apple.com, it is impossible yet. :frowning:

Check this: http://bbs.applescript.net/viewtopic.php?t=6093
You can use something as:

osascript -e '(load script alias "path:to:script")'s whateverHandler("argument")'