Re: Mac OS alias from Perl

2007-12-09 Thread Dave Gomez
For the traditional method if you can't find a module or common method  
just use the quote below the tilde, ie `ln -s /path/to/my/interest / 
path/to/my/alias`, note if this will run in a cron, you will have to  
give the full path ot ln, just do a whereis ln command (mine and  
yours should be in /bin.


Dave

On Dec 8, 2007, at 7:19 PM, Chris Devers wrote:

On Dec 8, 2007, at 7:06 PM, Celeste Suliin Burris [EMAIL PROTECTED] 
 wrote:


Use a symbolic link instead.  Perl handles those natively, and they  
can be
accessed from the command line. The Finder just treats them the  
same as

aliases.





Not quite. I forget the details at the moment, but Finder aliases  
are kind of like firm links: while hardlinks point to inodes, and  
softlinks point to file pathnames, aliases point to the logical file  
in a more robust way than symlinks. For example, if the reverent  
file moves, symlinks break, but aliases shouldn't.


If you really want aliases, I think the CPAN modules of Dan Kogai  
and Chris Nandor are the place to start. I forget who wrote what,  
but modules like (I think) MacOS::File and Mac::Glue can either make  
the right calls directly, or leverage Applescript / OSAscript to do  
this for you.


Or if symlinks/softlinks are enough, just use the traditional Perl /  
Unix methods to make those.



--
Chris Devers




Re: Mac OS alias from Perl

2007-12-09 Thread Peter N Lewis

At 19:01 -0500 8/12/07, Dan Neville wrote:
Does anyone know how to make a Mac OS alias in Perl?  So, I wish to 
have Perl create aliases in multiple directories rather than copy 
the original file.


There actually is no API call to create an alias file.

You can do it in Perl as described at

http://use.perl.org/~pudge/journal/10437

Alternatively, you can make a new alias via AppleScripting the Finder as:

set thaAlias to Harddisk:Users:peter:thefile.cpp as alias

tell application Finder
set f to make new alias file at desktop to thaAlias
end tell
f

Which will return the alias file created.

Enjoy,
   Peter.

--
Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac
http://www.stairways.com/   http://download.stairways.com/


Re: Mac OS alias from Perl

2007-12-09 Thread Doug McNutt
At 20:11 +0900 12/9/07, Peter N Lewis wrote:
At 19:01 -0500 8/12/07, Dan Neville wrote:
Does anyone know how to make a Mac OS alias in Perl?  So, I wish to have Perl 
create aliases in multiple directories rather than copy the original file.

There actually is no API call to create an alias file.

You can do it in Perl as described at

http://use.perl.org/~pudge/journal/10437

Alternatively, you can make a new alias via AppleScripting the Finder as:

set thaAlias to Harddisk:Users:peter:thefile.cpp as alias

tell application Finder
   set f to make new alias file at desktop to thaAlias
end tell

If you're not into the O-O stuff involved with the AppleScript modules, and 
you're not in a hurry, it's possible to invoke the osascript tool from within 
perl using backticks. You can create a string of AppleScript commands to pass 
to it with simple perl concatenations like .= or you can use a  here 
document with perl's here or with shell's here depending on how you set the 
backticks.

Test your AppleScript code with Script Editor first.

Using Finder is pretty much required because Finder owns the specification 
for an alias file. I have never seen a formal description of that or, for that 
matter, an alias resource. They are based on the file-id number which never 
repeats as files are created on a partition but there is more to it because 
that doesn't always work. Aliases do survive a file name change by the user and 
they use volume names so that Finder can request a floppy by name if an old 
alias pops up. What can cause an alias to fail is an editor that always writes 
the changed file to a newly created copy and then changes the names around so 
the original becomes the backup. The alias will point to the original while a 
symbolic link will point to the new.

-- 

Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.


Re: Mac OS alias from Perl

2007-12-09 Thread Michael Barto




Yes the alias function in MacOSX is different than regular Unix. If
your software is targets a Unix server and not to only run under
MacOSX, it is much better to make the links on the Mac at the command
line with Unix ln command (e.g. ln -s -which is safer) to test and
maintain a consistent Unix environment. Fortunately Mac support of
regular Unix is really excellent and ln works as advertise on a Mac. By
the way, another "got-you" is the Mac filesystem. On new Mac computers
where the software is pre-installed, the filesystem ignores case. The
is not true in regular Unix. For example: in regular Unix, a file name
like "johnsfile" and "johnsFile" are considered different file. But on
the Mac, they are considered the same. But you have a true Unix
filesystem by reformating the disk to support case sensitive file
naming. This has hurt me several times till I reformated my drive.

Chris Devers wrote:
On Dec 8, 2007, at 7:06 PM, Celeste Suliin Burris
[EMAIL PROTECTED] wrote:
  
  
  Use a symbolic link instead. Perl handles
those natively, and they can be

accessed from the command line. The Finder just treats them the same as

aliases.


  

  
  
Not quite. I forget the details at the moment, but Finder aliases are
kind of like "firm links": while hardlinks point to inodes, and
softlinks point to file pathnames, aliases point to the logical file in
a more robust way than symlinks. For example, if the reverent file
moves, symlinks break, but aliases shouldn't.
  
  
If you really want aliases, I think the CPAN modules of Dan Kogai and
Chris Nandor are the place to start. I forget who wrote what, but
modules like (I think) MacOS::File and Mac::Glue can either make the
right calls directly, or leverage Applescript / OSAscript to do this
for you.
  
  
Or if symlinks/softlinks are enough, just use the traditional Perl /
Unix methods to make those.
  
  
  


-- 





  

  
  


  Michael Barto
  Software Architect
  
  
  
  


   LogiQwest
Inc.
16458 Bolsa Chica Street, # 15
Huntington Beach, CA92649
  http://www.logiqwest.com/
  
  
  
  [EMAIL PROTECTED]
Tel:714 377 3705
Fax:714 840 3937
Cell: 714 883 1949
  
  


  'tis a gift to be
simple
   


   This e-mail may contain
LogiQwest
proprietary information and should be treated as confidential. 

  








Re: Mac OS alias from Perl

2007-12-09 Thread brian d foy
[[ This message was both posted and mailed: see
   the To, Cc, and Newsgroups headers for details. ]]

In article [EMAIL PROTECTED], Dan Neville
[EMAIL PROTECTED] wrote:

 Hello,
 Does anyone know how to make a Mac OS alias in Perl?  So, I wish to 
 have Perl create aliases in multiple directories rather than copy the 
 original file.

I've now create MacOSX::Alias based on Chris's code. It's on CPAN as a
developer release right now.