• 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: Passing data to & from shell scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing data to & from shell scripts


  • Subject: Re: Passing data to & from shell scripts
  • From: Philip Aker <email@hidden>
  • Date: Sun, 02 Feb 2003 12:12:52 -0800

On Saturday, February 1, 2003, at 11:23 AM, Larry McMunn wrote:

I'm new to shell scripts and the Unix side of OSX. Right now I'm
working on replacing the functions of the RegEx scripting addition in
OS9. With the help of a couple of readers of this list, I have this
shell script that really rocks:
-------------------
--delete certain strings
set fromString to "(Some text to delete |\\t\\d{8})" --the second
item is a date string like "20030131"
set toString to ""
set theDATA to do shell script "perl -e '$_ = \"" & theDATA & "\";
s/" & fromString & "/" & toString & "/g; print $_.\"\\n\";'"

--replace certain strings
set fromString to " *\\t *"
set toString to "\\t"
set theDATA to do shell script "perl -e '$_ = \"" & theDATA & "\";
s/" & fromString & "/" & toString & "/g; print $_.\"\\n\";'"
---------------------


One problem--while my O'Reilly's "Learning Perl" seems to indicate
that strings in Perl can be of any length (depending on memory of
course). Working with a text file of 87027 characters, I have found
the following:

At 65296 characters or less, it's beautiful! However, there is a
problem with larger strings.

With the complete string,
it failed with this message--"An error of type 255 has occurred."

-->>This made me suspect that Applescript couldn't handle passing a
variable this size. However, I routinely read strings much, much
larger than this into variables and work with them.

At 65299 and some slightly larger sizes that I tried,
it returns this error message--"sh: /usr/bin/perl: Argument list too long".

-->>This has me wondering if perl doesn't want to see a string this long.

Interestingly at string sizes 65298 and 65297 characters,
it totally locks up my machine.

-->> This blows me away. I've had applications crash and lock up in
OSX, but I've always been able to do a force quit, and continue
working with other apps. This time, the machine is frozen, requiring
a complete restart.

I'm on a 800Mz TiBook with 1Gb memory, OSX 10.2.3 with perl 5.6, so I
have plenty of power for doing this. I use Script Debugger 3.0.5, but
in Script Editor I get the results.

Has anyone else had anything like this?

Yes, same kind of thing happening when I use Tcl's regsub command with a data file of ~92K. I've adapted it to take the name of a file for input. Getting 92K of data back works fine (OS X 10.2.3 as well). Drop me a note if you can use the script. It's small, fast, and doesn't require the heavy quoting you're using in the Perl example above.

Cheers,


Philip Aker
http://www.aker.ca
_______________________________________________
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.

References: 
 >Passing data to & from shell scripts (From: Larry McMunn <email@hidden>)

  • Prev by Date: Re: Name of current users home folder (OS X)
  • Next by Date: Re: Accessing a 'Scripting Addition's Features
  • Previous by thread: Passing data to & from shell scripts
  • Next by thread: mail.app question: setting the subject
  • Index(es):
    • Date
    • Thread