• 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: perl from applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >perl from applescript (From: John Fowler <email@hidden>)
 >Re: perl from applescript (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: ANNOUNCE: Record & List Tools 1.0.2
  • Next by Date: Re: perl from applescript
  • Previous by thread: Re: perl from applescript
  • Next by thread: Re: perl from applescript
  • Index(es):
    • Date
    • Thread