I know this is an old thread, but can someone give more details on how to
make this work? :)
I followed these directions:
<snip>
Yes! This is working. I just changed the Hello World example with this
script:
on clicked theObject
tell main bundle to set thePath to path for resource "stats"
extension "perl"
try
set thePath to "\"" & thePath & "\""
set r to do shell script thePath
display dialog r
on error msgError
display dialog msgError
display dialog thePath
end try
end clicked
And put a stats.perl file in the Resources folder with this snippet:
#!/usr/bin/perl
use strict;
my $r = scalar (localtime);
print $r;
And then build the Hello World app and its working. The only problem
that I had was that I forgot to set executable bit on the stats.perl
file.
Wow, this is very very cool!!!!
</snip>
But all I get is a window with nothing in it, and if I run it in Project
builder, I get a red text thingy that says that the applescript has exited
with a status of '0'
Anyone understand what's going on, or have a working example they can share?
I'm confused on what kind of project I'm supposed to make and when and what
I chmod the Perl script to, do I open up the bundle and do it there?
Justin Simoni
--
+ Freelance Web Design
+ Internet Application Development
[EMAIL PROTECTED] | http://justinsimoni | 720.436.7701
> Hello,
>
> I just had this conversation on the AppleScript Studio list with Tim
> Bumgarner, the lead developer, and thought that some people on this
> list might be interested.
>
> If you want to use a little bit of AppleScript for manipulating the
> UI, you could build easily Perl app with a nice Aqua interface.
>
>> � (At) 23:36 -0500 17/12/01, Emmanuel. M. Decarie �crivait (wrote) :
>>>
>>>> *** 2. Can I put a Perl script or any other text file containing
>>>> shell commands in the project that I could call from
>>>> Application.applescript?
>>>>
>>>> Suppose I want to build an AS Studio app that will open a window
>>>> to choose a file, and then pass the path to the file to a Perl
>>>> script that will sort every words in the file alphabetically with
>>>> the number of occurrences for each word, and then return back the
>>>> stats to the user in a new window.
>>>>
>>>> - Could I embed the Perl script file in the project?
>>>> - If so, how do I get the path to this file to be able to run it
>>>> from Application.applescript (i.e do shell script "path in to my
>>>> Perl script")
>>>>
>>> I don't have any experience with perl, but you should be able to do
>>> the following:
>>>
>>> 1. Create a perl script, say 'stats.perl'.
>>> 2. Add it to your project. This will typically end up in the
>>> 'Bundle Resources' build phase which usually put's it's products
>>> into 'Contents/Resources' inside of your built application.
>>> 3. Do the following somewhere in your script: 'tell main bundle to
>>> set thePath to path for resource "stats" extension "perl"'. This
>>> will return the full POSIX path to your 'stats.perl' script that is
>>> in your built application.
>>> 4. Pass that path to an execution of 'do shell script'. I'm not
>>> sure how to invoke a perl script, but I think you get the idea.
>>>
>>> You can check out the 'path for' command for more variants. It
>>> listed in the Application Suite.
>>
>> Yes! This is working. I just changed the Hello World example with this
>> script:
>>
>> on clicked theObject
>> tell main bundle to set thePath to path for resource "stats"
>> extension "perl"
>> try
>> set thePath to "\"" & thePath & "\""
>> set r to do shell script thePath
>> display dialog r
>> on error msgError
>> display dialog msgError
>> display dialog thePath
>> end try
>> end clicked
>>
>> And put a stats.perl file in the Resources folder with this snippet:
>>
>> #!/usr/bin/perl
>>
>> use strict;
>>
>> my $r = scalar (localtime);
>>
>> print $r;
>>
>> And then build the Hello World app and its working. The only problem
>> that I had was that I forgot to set executable bit on the stats.perl
>> file.
>>
>> Wow, this is very very cool!!!!
>>
>
> AppleScript Studio list:
> <http://www.lists.apple.com/mailman/listinfo/applescript-studio>