• 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: Shell-sandwich a file in 2 variable strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell-sandwich a file in 2 variable strings


  • Subject: Re: Shell-sandwich a file in 2 variable strings
  • From: Michael Terry <email@hidden>
  • Date: Fri, 6 Feb 2004 22:23:17 -0800

On Feb 6, 2004, at 6:20 PM, Gnarlodious wrote:

I lost track of this discussion, but I am saying

do shell script "echo " & quoted form of startHTML & " $(<" & flopPOSIX & ")
" & quoted form of endHTML & ">>" & iPathPOSIX

Where flopPOSIX may be any huge file depending on the database size. Is this
command line safe from threats of amputation? I guess I don't know if I am
running it through a shell variable or what.


Yes, you're passing command line arguments, and it will fail if the quoted forms of startHTML, flopPosix, endHTML, and iPathPosix, plus the default environment variables of 'do shell script''s shell exceed its limit--a quarter MB in Panther, and before that even less.

-------------------------------------------------------------------
-- get a value that equals Panther's limit for command line args
-------------------------------------------------------------------
set args to "a"
repeat until args's length 3 262144
set args to args & args
end repeat
set args to args's text 1 thru 262144

try
-------------------------------------------------------------
-- try to pass it as a command line argument
-------------------------------------------------------------
do shell script "echo " & args
on error
-------------------------------------------------------------
-- that didn't work, let's fix it
-------------------------------------------------------------
say "Oops, forgot about the environment variables!"
set approxEnvLen to (do shell script "env")'s length
set args to args's text 1 thru (262144 - approxEnvLen)
do shell script "echo " & args
say "There we go, that's better."
end try

What you could do to avoid it is write a temporary file with read/write commands and then use the shell command 'cat' in place of 'echo'.


Mike
_______________________________________________
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: Shell-sandwich a file in 2 variable strings
      • From: Gnarlodious <email@hidden>
    • Re: Shell-sandwich a file in 2 variable strings
      • From: Michael Terry <email@hidden>
References: 
 >Re: Shell-sandwich a file in 2 variable strings (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: Regex in OS X
  • Next by Date: Re: Regex in OS X
  • Previous by thread: Re: Shell-sandwich a file in 2 variable strings
  • Next by thread: Re: Shell-sandwich a file in 2 variable strings
  • Index(es):
    • Date
    • Thread