Passing data to & from shell scripts
Passing data to & from shell scripts
- Subject: Passing data to & from shell scripts
- From: Larry McMunn <email@hidden>
- Date: Sat, 1 Feb 2003 14:23:16 -0500
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?
--
Happy Automation! :-)
Larry McMunn
President
McMunn Associates, Inc.
Specialists in automated Data Visualization through Apple products
Collingswood, NJ
(856) 858-3440
---------------------------------------------------------------
_______________________________________________
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.