Hey everyone,
I need to literally pass the character \ (ASCII character 92) to a terminal command. I have tried using the notation above, as well as \ and a few others, but it still thinks I am trying to tell it that something is coming next that needs to be literal.
Any advice oh magical forum wizards?
Thanks!
Have you tried using quotes?:
do shell script "echo '\\'"
or
do shell script "echo " & quoted form of (ASCII character 92)
Using ’ inside of a quote just seems to pass on the character '.
“''” Also fails.
quoted form of (ASCII character 92) gives me '' when all I need is the \
Any more ideas?
I think I need to know a bit more. What are you trying to do with this?
I want applescript to be able to “do shell script” this:
echo “"test"” >> test.txt
so that text.txt contains: “test”
Okay cool. Try this:
set the_text to "test"
do shell script "cd ~; echo " & quoted form of the_text & " >> test.txt"
The problem with that is that the file ends up only containing the words text without the quotes. (I want the quotes to be in the text file).
The main reason I am doing this is that applescripts file read/write abilities seem to be unreliable when dealing with different types of data, and much more prone to breaking (guess I got spoiled with perl’s).
Found it out, It was in the apple docs all along (I guess I kind of discounted them after having a certain number be totally unhelpful and weird to read).
The solution has me doing this:
do shell script "echo \" \\\"test\\\" \" >> file.txt"
Sorry bout that and thanks again guys
But that gives me (if I open it in TextEdit) this:
Don’t you want this?:
Qwerty, thezanman’s script works for me.