Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Here's a command that works fine when I paste it into the Mac Terminal window:

echo -n -e \\033]0\;My Custom Window Title Here\\007 ; ping

In particular, it sets the Terminal's title to include the string "My Custom Window Title Here", then starts pinging

Now what I want to do is have the above command run in a separate Terminal window instead, so I enter this:

osascript -e 'tell app "Terminal" to do shell script "echo -n -e \\033]0\;My Custom Window Title Here\\007 ; ping"'

… but all I get is this error:

dyld: DYLD_ environment variables being ignored because main executable
(/usr/bin/osascript) is code signed with entitlements 59:60: syntax error: Expected “"” but found unknown token. (-2741)

If I get rid of the backslashes, osascript will run the command, but then of course the custom window title doesn't get set.

Is there some way I can get my bash command through osascript's parser intact, so that I can have my ping command execute in its own window AND with a customized window title?

share|improve this question
Expected “"” but found unknown token... –  Buscar웃 Mar 31 '14 at 23:20

1 Answer 1

up vote 3 down vote accepted

Because it's going through another layer of interpretation, you need to escape the escapes -- essentially, you need to double the backslashes:

osascript -e 'tell app "Terminal" to do script "echo -n -e \\\\033]0\\;My Custom Window Title Here\\\\007 ; ping"'
share|improve this answer
do shell script is not a Terminal command. Use "do script" instead. –  adayzdone Apr 1 '14 at 4:13
@adayzdone: good point. "do shell script" is a built-in AppleScript command, which can be executed by Terminal and sort-or-works... but not quite. I've edited the code snippet. –  Gordon Davisson Apr 1 '14 at 5:23
That did the trick, thanks! :) –  Jeremy Friesner Apr 1 '14 at 5:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.