views:

28

answers:

2

My script looks like this, really simple

tell application "Terminal"
    do script "cd myapp"
    do script "heroku console" in window 1
    do script "User.count" in window 1
end tell

But I get an "Error in the AppleEvent Routine". What is wrong with this script? If I type the commands in the Terminal it works.

A: 

This command means nothing... cd myapp. You have to give the full path to myapp like ~/myapp. Also you should run them as 1 command by putting a semicolon between them...

tell application "Terminal"
    do script "cd path/to/myapp; heroku console; User.count"
end tell
regulus6633
hmmm, the User.count command doesn't work. Maybe the remote heroku console doesn't accept Applescript commands?
tabaluga
+1  A: 

That's probably not working because heroku console doesn't return you to the shell after it finishes, it starts the interactive console.

What you need is something that will run and return. Fortunately this is totally possible with Heroku:

heroku console 'User.count'

You can call console with a command to run as the argument. Then it returns the result immediately instead of starting up the interactive session. Sounds perfect for you!

tfe
wow! that is great thanks!
tabaluga