• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: do shell script - any limit to text argument?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script - any limit to text argument?


  • Subject: Re: do shell script - any limit to text argument?
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 8 Apr 2003 00:37:35 -0700

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
_______________________________________________
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.

  • Follow-Ups:
    • Re: do shell script - any limit to text argument?
      • From: Donald Hall <email@hidden>
    • Re: do shell script - any limit to text argument?
      • From: "Robert C. Jacobson" <email@hidden>
References: 
 >do shell script - any limit to text argument? (From: Donald Hall <email@hidden>)

  • Prev by Date: Re: Can't get the application's event dictionary
  • Next by Date: Unicode characters
  • Previous by thread: do shell script - any limit to text argument?
  • Next by thread: Re: do shell script - any limit to text argument?
  • Index(es):
    • Date
    • Thread