Re: Shell-sandwich a file in 2 variable strings
Re: Shell-sandwich a file in 2 variable strings
- Subject: Re: Shell-sandwich a file in 2 variable strings
- From: Gnarlodious <email@hidden>
- Date: Sat, 07 Feb 2004 12:42:23 -0700
Thanks Michael for that exhaustive discussion, it's been very educational.
-- Gnarlie
Entity Michael Terry spoke thus:
>
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'.
_______________________________________________
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.