Re: perl from applescript
Re: perl from applescript
- Subject: Re: perl from applescript
- From: John Fowler <email@hidden>
- Date: Sun, 28 Aug 2005 11:40:48 -0500
Thanks. I had figured out how to do this if I was limited to processing a string. I was wondering whether there was a way to receive a list construct as such, but apparently not. Thanks.
John Fowler
On Aug 28, 2005, at 10:29 AM, Daniel Jalkut wrote:
Hi John - it depends on the format of the output from your perl script. Since "do shell script" will always return a string, you have to parse the results back into something manageable by AppleScript. Here's an extremely simple example:
#!/usr/bin/perl
print "1 2 3 4 5 6 7 8 9 10\n";
I saved this to a file in "/tmp/TestPerl.pl". Since the output is just a simple list of numbers separated by spaces, I can use AppleScript's default text delimiters to help with parsing the output. By setting the delimiter to the space character:
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set myResult to do shell script "/tmp/TestList.pl"
set myItems to text items of myResult
set AppleScript's text item delimiters to oldDelim
myItems
I end up with output from the script as an easily managed list:
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}
Hope this helps,
Daniel
On Aug 28, 2005, at 10:28 AM, John Fowler wrote:
I am interested in activating a perl script from an applescript and receiving a list of items back from the perl script, using "do shell script."
I have the perl script working. How do I receive a list of items back from do shell script?
John Fowler
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden