do shell script "echo" question

Hello,

I have a question regarding echo and how to get a string to turn out the way I intend it to . I have this little snippet which I want to pass to echo to write to a file. It writes to the file but I am trying to get “quotes” around the outputted text.

This will write EPG=ENG,dallas to the file instead of the intended EPG=ENG,“dallas”


set theProduct to "dallas"
set thestring to "echo EPG=ENG,\"" & theProduct & "\">>Dallas.txt"
do shell script thestring

If you return thestring though and copy the text between the start and end quotes into bash you end up with the right result

echo EPG=ENG,"dallas">>Dallas.txt ← I have removed the start/end quotes to copy it into bash.
EPG=ENG,“dallas”

Anyone know how I can make this work?
Thanks
Dallas


set theProduct to "dallas"
set thestring to "echo 'EPG=ENG,\"" & theProduct & "\"' >> Dallas.txt"
do shell script thestring

You need to enclose the desired string to write within single quotes:


set theProduct to "dallas"
set thestring to "echo 'EPG=ENG,\"" & theProduct & "\"'>>Dallas.txt"
do shell script thestring

Hope this helps,

Worked great, and also thanks for the explanation of why you have to do it.
Dallas