How can I launch commands in new terminal windows? I've tried the below

open -a Terminal "" -e "/usr/local/bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties"
open -a Terminal "" -e "/usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties"

However I get

the file /usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties does not exist.

The file does exist: e.g. ls /usr/local/bin/kafka-server-start shows that the file is in there.

How can I tell it that the properities file is a parameter and not part of the path? Assuming this is the correct way to open a terminal with a new command.

I'm on MacOS Catalina, if it helps.

  • -e opens in TextEdit, also why use ""?
    – nohillside
    Jul 18, 2020 at 12:04
  • @nohillside I've tried now without "" -e thanks. I still get the same error Jul 18, 2020 at 12:21
  • Don‘t think it needs quotes for the rest either, from looking at the error message you get
    – nohillside
    Jul 18, 2020 at 12:34
  • @nohillside It gives the same error with or without quotes Jul 18, 2020 at 12:38

1 Answer 1


This is what you're looking for:

osascript -e 'tell application "Terminal"' -e 'do script "/usr/local/bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties"' -e 'do script "/usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties"' -e 'end tell'

It can also be done as:

osascript <<-EOF 
tell application "Terminal"
    do script "/usr/local/bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties"
    do script "/usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties"
end tell

Or like so:


tell application "Terminal"
    do script "/usr/local/bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties"
    do script "/usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties"
end tell
  • probably close. I get 118:118: syntax error: Expected end of line but found end of script. (-2741) Jul 18, 2020 at 13:09
  • @Koenig Lear, I do not have the programs you're trying to start so I cannot test; however, these commands work for me when replaced with simple do script say \"hello\" or do script say "hello" depending on the method invoked. Jul 18, 2020 at 13:15
  • It's working now (the OAS version) thanks, there was a missing backslash. Jul 18, 2020 at 13:17
  • @Koenig Lear, Okay, thanks... I put the missing slash / in. Jul 18, 2020 at 13:19
  • @nohillside, Thanks... I totally missed that space. :) Jul 18, 2020 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .