[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Deleting files & interaction with AppleScript



At 03.47 -0500 1999.01.07, G. Ann Campbell wrote:
>I've got two questions today. First, how do you have MacPerl delete a file? My
>Perl for dummies suggests unlink, which doesn't seem to work. Do you just
>rename it to the trash directory? And if so, do you rename it to the trash
>directory on the volume it's on, or to your own trash?

First, it has been said that Dummies books are like certain illicit drugs:
they are designed to keep you coming back for more.  Or, less subtly, books
for dummies keep you that way.  Just a bit of advice.  What book would I
recommend?  Well, I personally (and somewhat biasedly) recommend MacPerl:
Power and Ease.

Second, unlink() does work fine in MacPerl.  Did you check the result of
the unlink()?  Did Perl for Dummies tell you to check the error?

  unlink($file) or die "Can't unlink $file: $!";

Chances are that you have the wrong path or something.  unlink() does work
fine.


>Also, I've got the following as the last step in a MacPerl script:
>
>&MacPerl'DoAppleScript(<<'END_SCRIPT');
>tell application "Finder"
>	activate
>	select file "Fetch 3.0.3" of folder "Fetch 3.0.3 Folder" of folder
>"Applications" of startup disk
>	open selection
>end tell
>tell application "Fetch 3.0.3"
> 	activate
> 	make new transfer window at beginning with properties
>{hostname:"lagrangenews.com", initial directory:"www"}
> 	put into transfer window "lagrangenews.com" item alias "ADVERTISING
>1:Publish:Classified:"
>end tell
>END_SCRIPT
>
>I used the AppleScript record function to get the code, but when I run it from
>MacPerl, a dialog pops up asking me where Fetch is - even though it's got the
>exact path in proper AppleScript syntax.

AppleScript works kinda funny with application names like that.  In
AppleScript, you find it once, and it is saved in the compiled script.
MacPerl does not have compiled AppleScripts, they must be compiled each
time (which is a big reason why AppleScripts from MacPerl can be so slow to
start).

You can probably fix it by putting the whole path in there:

    tell application "Bourque:Communications:FTP:Anarchie Pro 3.5:Anarchie Pro"
        activate
    end tell

That works for me.

You might want to consider using Mac::Apps::Anarchie, on my site and on
CPAN, which can control Anarchie and Fetch for you using AppleEvents.
Also, you might want to use Net::FTP, which comes with MacPerl, which does
the FTP for you, instead of using another app.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch