Re: do shell script - any limit to text argument?
Re: do shell script - any limit to text argument?
- Subject: Re: do shell script - any limit to text argument?
- From: Donald Hall <email@hidden>
- Date: Tue, 8 Apr 2003 23:01:03 -0600
Thanks to Chris, Ivan, and Robert for answering my question. I was
afraid it might be something small like 255 bytes.
Don
>
On Monday, April 7, 2003, at 09:23 PM, Donald Hall wrote:
>
>
>I don't think TN2065 mentions anywhere a restriction on the length
>
>of the text argument to 'do shell script'. Is there one? Could I
>
>put a large shell script in a text file, read it in, and execute it
>
>with 'do shell script'?
>
>
As a matter of fact, I just submitted a revised version that answers
>
this question:
>
>
Q: How long can my command be? What's the maximum number of characters?
>
A: There is no precise answer to this question. (See Gory Details
>
for the reasons why.) However, the approximate answer is that a
>
single command can be up to about 65,000 characters long --
>
technically, 65,000 bytes, assuming one byte per character.
>
Non-ASCII characters will use at least two bytes per character --
>
see Dealing With Text for more details.
>
>
Overrunning the limit will cause do shell script to return an error
>
of type 255. Most people who hit the limit are trying to feed inline
>
data to their command. Consider writing the data to a file and
>
reading it from there instead.
>
>
Q: How long can my command be, really?
>
A: Calling do shell script creates a new sh process, and is
>
therefore subject to the system's normal limits on passing data to
>
new processes: the arguments (in this case, the text of your command
>
plus about 40 bytes of overhead) and any environment variables may
>
not be larger than NCARGS, which is currently 65,536 bytes. Because
>
do shell script inherits its parent's environment (see the next
>
question), the exact amount of space available for command text
>
depends on the calling environment. In practical terms, this comes
>
out to somewhat more than 65,000 bytes, but unusual environment
>
settings might reduce that substantially.
>
>
>
--Chris Nebel
>
Apple Development Tools
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
email@hidden
http://www.appsandmore.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.