1

I am trying to create a service using Automator.

Inside a Run AppleScript action I have a variable that is a string in which each line is a word separated by linefeed. Like this:

à
às
a
ante
ao
aos
após
aquela

When I try to echo this to terminal by doing:

do shell script "echo " & (finalText as string)

I get this error:

The action “Run AppleScript” encountered an error: “sh: line 1: a: command not found
sh: line 2: à: command not found
sh: line 3: ante: command not found
...
sh: -c: line 30: syntax error near unexpected token `do'
sh: -c: line 30: `do'”

Any ideas?

2
  • When you say "trying to echo a string variable to Bash" what is it exactly your are trying to do? I ask because using a do shell script command in a Run AppleScript action isn't going to do much of anything if all you are doing is echoing some strings of text, however, from the errors you are obviously doing more than that! Anyway, to get rid of the command not found type errors, use: do shell script "echo " & finalText's quoted form -- As to the syntax error near unexpected token `do' error, without seeing all of the code, it's impossible to troubleshoot. Commented Nov 15, 2020 at 13:11
  • BRILLIANT. 's quoted form did the trick. Please make this command an answer, so I can accept. Commented Nov 15, 2020 at 13:19

1 Answer 1

1

To get rid of the command not found type errors in this case, and just about anytime when passing a variable to a do shell script command, use:

do shell script "echo " & finalText's quoted form

You can also use:

do shell script "echo " & quoted form of finalText

Whichever you prefer as appropriate.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.