I’m having a problem with reading file contents into a string. Here is the code:
set test to do shell script "cat /Applications/Quake3/baseq3/iquake.cfg"
set content of text field "readTest" to test
This gives me an error:
Can’t make «class conT» of «class texF» “readTest” into type reference. (-1700)
I’m not sure if this is the right shell script to get the content of a text file, but at least in Terminal it showed me the line I had in my file. Any suggestions?
PS: I’m not sure if this is the right forum, but I’m doing the project in AppleScript Studio, so I guess it’s the right forum
sh: -c: line 1: syntax error near unexpected token text' sh: -c: line 1: echo (text) > /Applications/Quake3/baseq3/iquake.cfg’ (2)
Those () are the problems, but I need those to write some content into the text file. I tried without () and it worked. I guess it’s some sort of a unix thing, but I don’t know how to get rid of the error …
Why are you using shell scripts to read and write to files? Applescript has built in commands for this, and they should provide you with all you need to write simple text to files and more. Do a search for “write to file” for plenty of examples.
Because I couldn’t get those read from file and write to file work. Said something bad file or whatever. Besides, the shell scripts gave me alot more answers on google and I decided to go with those. Anyway, StefanK, thanks alot, it worked!