I'm trying to do
echo "foo
foo
foo
....[many many lines of foo here]
foo" > "/Users/myname/destination.txt"
through Applescript, but it returns an error when the characters in the lines of foo hit some amount (It looks like it's 255392 characters.).
By "through Applescript," I mean I'm trying this with AppleScript's "do shell script", which stops process when the exit status is non-zero and returns this: "error "The command exited with a non-zero status." number 255
Here's my Applescript code:
set mytext to "foo
foo
foo
....[many many lines of foo here]
foo"
do shell script ("echo " & quoted form of mytext & " > " & "/Users/myname/destination.txt")
The actual big text data (20000+ lines, 285831 characters) I use for input has a lot of quotation marks and backslashes, and I don't want to mess up my files by put my text data directly into terminal and have it misinterpret some parts of my input text data as commands or file names, so I'm not checking this directly with bash yet.
It might be more of an Applescript's problem, but I thought I might get response sooner here, so I'm posting this here.
Is there a limit of characters of input text in echo, or something? How can I avoid this?
Edit: I wrote this in a shell script and ran it on terminal and it worked but I'd like to do this through Applescript and I don't have no idea why doesn't this work in Applescript :
#!/bin/bash
echo "aaaaaaa[100000+ "a"s in here]aaaa" > "/Users/myname/destination.txt"
echo
. The fix is simple: Don't do it all in one command. And don't useecho
. What are you actually trying to achieve, though? This seems several layers removed from your actual use case, which may be handled directly with a shell script.echo "foo" >> "/Users/myname/destination.txt"
, but I can't prepend text to it.aaaaaaa[100000+ as]aaaa
if you look in your file.[100000+ "a"s in here]
. The actual input string I tested didn't have quotation marks.<irony-mode>
There's actually an invention that's designed to contain really really big sequences of bytes, like 100K or more, and be easily handled by any programming language with an extremely short reference to it. It's even built into Mac OS X! It's called a "file."</irony-mode>
;)