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

Re: [MacPerl] Deleting files & interaction with AppleScript



On Thu, Jan 07, 1999 at 08:47:25AM +0000, G. Ann Campbell wrote:
} Morning, all (or whenever it is where you are)
} 
} 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?

You use unlink, but you should be aware that this means permanent
removal, not simply moving to the trash. You should check the return
value:

unlink($path) or print "Unable to remove $path $!\n";

which may give you some idea of what's going on.  unlink works.

What do you see happening?

Alternatively you can rename into the trash.  The trash is a top level
folder on every volume, so you should rename it into the volume it's
on.  rename won't work across volumes.

} 
} Also, I've got the following as the last step in a MacPerl script:

Since all you're doing here is storing a file, why not simply
use Net::FTP?

} 
} &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.
} 
} And the really strange thing is that when I copy the AppleScript back out of
} my MacPerl document, paste it into a new AppleScript window and try to run it,
} AppleScript asks me where Fetch is - even though it has the proper path -
} because the path was recorded in AppleScript initially. But AppleScript only
} asks me the first time. After that it can find Fetch.
} 
} TIA for any and all light you can shed.
} 
} Ann
} 
} ***** Want to unsubscribe from this list?
} ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch
} 
} 

-- 
Paul Schinder
schinder@pobox.com

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