Re: Dumb path question

2009-03-10 Thread David Green
Remember also that the "caller" function can say what the location of  
the file (package) is, in relation to the host filesystem.  Read  
about it, it may be of use ;)


David


On 9 Mar, 2009, at 23:24, Chris Devers wrote:


This isn't necessarily a Mac-specific question, but I've gotten rusty
and I'm having a brain fart here.

How can a Perl script reliably, portably resolve the path inside which
it is running? Not the PWD of the caller, mind you, but the actual
current full path of the script itself?

Context: I have a pair of utility apps meant to be run in tandem. The
first is a Pashua questionnaire that shows some forms and saves  
results
to a file. The second is a Platypus script that gets admin access  
(hence

needing another app -- I couldn't see how to get Pashua to prompt for
admin access), then uses the results from the first app to do some
`defaults write ...` & `sudo networksetup ...` type system calls.

Because the apps are meant to be distributed & run together, I've  
placed

the second one inside the Contents/Resources/ folder of the first one,
which finishes with (simplifying slightly):

  my $helper = "$ENV{'PWD'}/../Resources/Helper.app";
  system("/usr/bin/open "$helper'") and die "Couldn't run $helper:  
$!";


If I first put the first app in /Applications, this works fine.

The problem is I can't rely on $ENV{'PWD'} having something useful.  
If I

move the parent app from /Applications (to the Desktop, a USB drive, a
disk image, or a Samba volume), or if I invoke the Pashua script  
from a

shell, then the $helper variable typically ends up with something
useless (often but not always just "/../Resources/Helper.app") and the
second app never executes.

I've thought of a few ways around this (e.g. wrap the whole thing  
in an

installer package so I can force & depend on a single path), but they
all seem cumbersome to varying degrees. Ideally, it should behave  
like,

say, Firefox, where it will run the same way no matter where the user
wanted to put (or not bother to put) the app bundle.

Is there a common way to do this? What $ENV variables can be relied on
to have the full path to the running Perl script from which a working
relative path can be derived? Is there some other way that this is
already a Solved Problem, or should I just muddle through?

Any help very much appreciated :-)

Pashua:
http://www.bluem.net/en/mac/pashua/
http://macresearch.org/ 
command_line_tutorial_part_iii_windows_of_opportunity


Platypus:
http://www.sveinbjorn.org/platypus
http://www.macresearch.org/ 
command_line_tutorial_part_i_native_mac_apps_for_command_line_tools
http://www.macresearch.org/ 
command_line_tutorial_part_ii_making_progress_and_finding_options




--
Chris Devers


David Green
mrdgr...@mac.com

"Where you stand determines what you see." -- SAMUEL A. CULBERT



Re: Adding to @INC

2009-01-08 Thread David Green

I am guessing the bigger Perl has debug information within the program.

(lurking) David Green



On 8 Jan, 2009, at 0:36, Vic Norton wrote:

That is exactly what has happened, Sherm. Thanks a lot. Prior to my  
recent installation of Leopard, I had used MacPorts to install  
Perl5.8.8. So I have 5.8.8 in two places, in /usr/bin and in /opt/ 
local/bin. And /opt/local/bin comes earlier in my PATH than /usr/bin.


I'm going to have to think about this. Thanks for the aside!

Another curiosity. I just checked out the Perl5.8.8 files in /usr/ 
bin and /opt/local/bin. The /usr/bin one came with Leopard, which I  
bought from Apple a week or so ago. It was created on Dec 7, 2007,  
and it weighs 48 KB. The MacPorts perl was created on Sep 5, 2008,  
and weighs 1.1 MB. Why, I wonder, should one Perl5.8.8 be 25 times  
as big as another?


Regards,

Vic

On Jan 7, 2009, at 3:06 PM, Sherm Pendley wrote:


On Jan 7, 2009, at 10:24 AM, Vic Norton wrote:

I plan to use CPANPLUS to install new packages and modules. Right  
now it installs them in

/opt/local/lib/perl5/site_perl/5.8.8


As an aside, I think it's kind of odd that /usr/bin/perl would do  
that... Are you sure there's not an /opt/local/bin/perl earlier in  
your PATH? If you used MacPorts to install a newer Perl, that's  
where it would install it.


sherm--





David Green
mrdgr...@mac.com

"Where you stand determines what you see." -- SAMUEL A. CULBERT



Fwd: @INC troubles and fun

2008-09-12 Thread David Green

Actually it is possible the below is for use by Apache... (or both)


@INC

OK, I have dug up some information I found some time ago... The  
standard (Tiger) implementation of @INC can be modified or added to  
via: /Library/Perl/5.8.6/AppendToPath


I am assuming the equivalent in any installed version exists, but  
this will sort out 5.8.6.


I think that might help some headaches.




@INC troubles and fun

2008-09-12 Thread David Green

@INC

OK, I have dug up some information I found some time ago... The  
standard (Tiger) implementation of @INC can be modified or added to  
via: /Library/Perl/5.8.6/AppendToPath


I am assuming the equivalent in any installed version exists, but  
this will sort out 5.8.6.


I think that might help some headaches.


Re: Can't find Mac::Growl

2008-09-09 Thread David Green
OK, going back to fundamental issue, what or why is this failing or  
me (it failed the same first time, which is why I tried the  
'force' :-); I am using standard Tiger v5.8.6 of Perl:



cpan> force install Mac::Growl
CPAN: Storable loaded ok
Going to read /Users/dgringo/.cpan/Metadata
  Database was generated on Sun, 20 Jan 2008 02:39:47 GMT
Running install for module Mac::Growl
Running make for C/CN/CNANDOR/Mac-Growl-0.67.tar.gz
CPAN: Digest::MD5 loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for /Users/dgringo/.cpan/sources/authors/id/C/CN/CNANDOR/ 
Mac-Growl-0.67.tar.gz ok

Scanning cache /Users/dgringo/.cpan/build for sizes
Mac-Growl-0.67/
Mac-Growl-0.67/Changes
Mac-Growl-0.67/lib/
Mac-Growl-0.67/lib/Mac/
Mac-Growl-0.67/lib/Mac/Glue/
Mac-Growl-0.67/lib/Mac/Glue/glues/
Mac-Growl-0.67/lib/Mac/Glue/glues/GrowlHelperApp
Mac-Growl-0.67/lib/Mac/Glue/glues/GrowlHelperApp.pod
Mac-Growl-0.67/lib/Mac/Growl.pm
Mac-Growl-0.67/Makefile.PL
Mac-Growl-0.67/MANIFEST
Mac-Growl-0.67/README
Mac-Growl-0.67/t/
Mac-Growl-0.67/t/Mac-Growl.t
Removing previously used /Users/dgringo/.cpan/build/Mac-Growl-0.67

  CPAN.pm: Going to build C/CN/CNANDOR/Mac-Growl-0.67.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Mac::Growl
make: *** No targets specified and no makefile found.  Stop.
  /usr/bin/make  -- NOT OK
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible

cpan>





Re: MacPort: how to port perl?

2008-09-08 Thread David Green
Things you may need to consider (as I had removed my 5.8.8 some time  
back -- regarding Perl, I use a standard Tiger installation);

- where is your shell PATH pointing?
- where is your editor looking (might be the same as above) ?
- is the script executable or do you prefix running it with the  
actual command "perl" and, thus, which Perl (again) ?

- I thought PERL5LIB _was_ defined somewhere... I can not remember.

David




On 7 Sep, 2008, at 18:23, Vic Norton wrote:


On Sep 7, 2008, at 11:42 AM, David Green wrote:

Do you have an issue of Perl versions here -- 5.8.6 having been  
upgraded to 5.8.8?  I never solved the issue myself; ultimately I  
just stayed with the OS X standard or 5.8.8 and removed MacPorts.   
Would love for some clued in explanations ;)


I can not remember the details of what I was trying but I guess it  
was less important then having a fully 'aware' Perl installation.


David


Hi David,

As far as I can tell Perl on a Mac pays absolutely no attention the  
environmental variable PERL5LIB. I have eliminated all PERL5LIB  
specifications on my machine.


Here are a couple of test scripts that illustrate my point.

Script 1
   [put either shebang line here]

   #!/usr/bin/perl -w
   #!/opt/local/bin/perl -w

   # test1.pl  - Test Perl constructs

   use strict;
   use Date::Format;

Script 2
   [put either shebang line here]

   #!/usr/bin/perl -w
   #!/opt/local/bin/perl -w

   # test2.pl  - Test Perl constructs

   use strict;
   use Crypt::SSLeay;

When I run Script 1, either from Terminal or from BBEdit, nothing  
happens with the top shebang line (Date::Format is in my /usr/bin/ 
perl [5.8.6] tree), but I get an error message listing @INC with  
the bottom shebang line (Date::Format is not in my /opt/local/bin/ 
perl [5.8.8] tree).


Just the opposite situation occurs when I run Script 2, either from  
Terminal or from BBEdit. I get an error message listing @INC with  
top bottom shebang line (Crypt::SSLeay is not in my /usr/bin/perl  
[5.8.6] tree), but nothing happens with the bottom shebang line  
(Crypt::SSLeay is in my /opt/local/bin/perl [5.8.8] tree).


I have found no way of running a module in one Perl tree with the  
other version of Perl.


Regards,

Vic





Re: MacPort: how to port perl?

2008-09-08 Thread David Green

What folders contain files to configure Perl ?


On 7 Sep, 2008, at 20:02, Doug McNutt wrote:


At 18:23 -0400 9/7/08, Vic Norton wrote:
As far as I can tell Perl on a Mac pays absolutely no attention  
the  environmental variable PERL5LIB. I have eliminated all  
PERL5LIB  specifications on my machine.


You WILL have that problem if you try to define PERL5LIB as an  
environment variable in your .profile or one of the *rc scripts.


If you define it in $HOME/.MacOSX/environment.plist it will  
actually be read at log in to aqua time and will be reflected in  
whatever shell script or bbedit worksheet that you open after that.


A login to MacOS neXt bears no resemblance to a login via ssh.

--
--> If  it's not  on  fire  it's  a  software  problem. <--




Re: MacPort: how to port perl?

2008-09-07 Thread David Green
Do you have an issue of Perl versions here -- 5.8.6 having been  
upgraded to 5.8.8?  I never solved the issue myself; ultimately I  
just stayed with the OS X standard or 5.8.8 and removed MacPorts.   
Would love for some clued in explanations ;)


I can not remember the details of what I was trying but I guess it  
was less important then having a fully 'aware' Perl installation.


David





On 7 Sep, 2008, at 10:09, Vic Norton wrote:

I want to access https URLs on the web via LPW. To do this I need  
Crypt::SSLeay.


I have not been able to install Crypt::SSLeay directly so I tried  
MacPorts. Everything seemed to go fine, but LPW::UserAgent says  
Crypt::SSLeay is not installed:


   501 Protocol scheme 'https' is not supported (Crypt::SSLeay not  
installed)


I can see Crypt::SSLeay in two places:
   /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level/Crypt/SSLeay
   /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level/auto/Crypt/ 
SSLeay

Right now I've got
   PERL5LIB=/Library/Perl/5.8.6:/opt/local/lib/perl5/vendor_perl/ 
5.8.8/darwin-2level
LPW insists Crypt::SSLeay is not installed. I've tried various  
other PER5LIB strings that seemed appropriate. None worked.


How do I get Perl to recognize a Perl module ported via MacPorts?  
In particular, how do I get LPW::UserAgent to see Crypt::SSLeay?


Thanks for any advice you van give me.

Regards,

Vic





Re: Can't find Mac::Growl

2008-08-26 Thread David Green
OK, I am slow -- certainly in catching up with the programatic use of  
Growl and, erm, OK, most of CPAN.


I think this is directly related to your issue but I am unable to  
fathom the solution myself.


I get this error:

cp lib/Mac/Growl.pm blib/lib/Mac/Growl.pm
cp lib/Mac/Glue/glues/GrowlHelperApp blib/lib/Mac/Glue/glues/ 
GrowlHelperApp
cp lib/Mac/Glue/glues/GrowlHelperApp.pod blib/lib/Mac/Glue/glues/ 
GrowlHelperApp.pod

Manifying blib/man3/Mac::Growl.3
Manifying blib/man3/Mac::Glue::glues::GrowlHelperApp.3
Can't locate Mac/Glue/Common.pm in @INC (@INC contains: /opt/local/ 
lib/perl5/5.8.8/darwin-2level /opt/local/lib/perl5/5.8.8 /opt/local/ 
lib/perl5/site_perl/5.8.8/darwin-2level /opt/local/lib/perl5/ 
site_perl/5.8.8 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/ 
vendor_perl/5.8.8/darwin-2level /opt/local/lib/perl5/vendor_perl/ 
5.8.8 /opt/local/lib/perl5/vendor_perl .) at /System/Library/Perl/ 
Extras/bin/gluemac line 26.
BEGIN failed--compilation aborted at /System/Library/Perl/Extras/ 
bin/gluemac line 26.

make: *** [.makeglue] Error 2



Do you think you can clue me in on my mistake(s) ?

Thanks,


David Green







On 23 Aug, 2008, at 12:20, WetMogwai wrote:


Thanks. Problem solved. I wonder why Apple couldn't do that before
shipping the OS. Seems I have a bug report to file.

On Aug 23, 9:22 am, [EMAIL PROTECTED] wrote:

Hola,

You can set that in your CPAN config I guess:

% locate Config.pm | grep CPAN

mine is:

/System/Library/Perl/5.8.8/CPAN/Config.pm

jonasbn

On 23/08/2008, at 05.33, WetMogwai wrote:







Re: Can't find Mac::Growl

2008-08-26 Thread David Green
Yes, that error I got was while trying to install Mac::Glue.  I have  
the standard 5.8.6 in the standard place but have also had to install  
5.8.8 for another reason.  They should not be clashing; 5.8.8 is  
normally used, but "#!/usr/bin/perl" still points to 5.8.6


I don't really need 5.8.8, as I was experimentally trying to use some  
other module(s) when it was added.  I do not use the new module(s) or  
need 5.8.8, but am not sure how to remove it.  Having said all that,  
your saying 5.8.6 has Mac::Glue already there, and if so, maybe part  
of my solution would be to downgrade to 5.8.6?


I am getting good with Perl but, holistically, I have some way to go  
with CPAN, etc.



David


On 25 Aug, 2008, at 20:32, Robert Grimm wrote:

It looks like you need to install Mac::Glue. Are you using some  
Perl distribution other than the standard one that comes with OS X?  
Mac::Glue was there for me, but my system doesn't have anything in / 
opt.


I'm having a similar, but much worse issue right now. I can't  
install any modules. Every time I try to install anything with  
CPAN, I get that error on ExtUtils::MakeMaker, which won't install  
because it isn't there.


On Aug 25, 2008, at 6:17 PM, David Green wrote:

OK, I am slow -- certainly in catching up with the programatic use  
of Growl and, erm, OK, most of CPAN.


I think this is directly related to your issue but I am unable to  
fathom the solution myself.


I get this error:

cp lib/Mac/Growl.pm blib/lib/Mac/Growl.pm
cp lib/Mac/Glue/glues/GrowlHelperApp blib/lib/Mac/Glue/glues/ 
GrowlHelperApp
cp lib/Mac/Glue/glues/GrowlHelperApp.pod blib/lib/Mac/Glue/glues/ 
GrowlHelperApp.pod

Manifying blib/man3/Mac::Growl.3
Manifying blib/man3/Mac::Glue::glues::GrowlHelperApp.3
Can't locate Mac/Glue/Common.pm in @INC (@INC contains: /opt/ 
local/lib/perl5/5.8.8/darwin-2level /opt/local/lib/perl5/5.8.8 / 
opt/local/lib/perl5/site_perl/5.8.8/darwin-2level /opt/local/lib/ 
perl5/site_perl/5.8.8 /opt/local/lib/perl5/site_perl /opt/local/ 
lib/perl5/vendor_perl/5.8.8/darwin-2level /opt/local/lib/perl5/ 
vendor_perl/5.8.8 /opt/local/lib/perl5/vendor_perl .) at /System/ 
Library/Perl/Extras/bin/gluemac line 26.
BEGIN failed--compilation aborted at /System/Library/Perl/Extras/ 
bin/gluemac line 26.

make: *** [.makeglue] Error 2



Do you think you can clue me in on my mistake(s) ?

Thanks,


David Green







On 23 Aug, 2008, at 12:20, WetMogwai wrote:


Thanks. Problem solved. I wonder why Apple couldn't do that before
shipping the OS. Seems I have a bug report to file.

On Aug 23, 9:22 am, [EMAIL PROTECTED] wrote:

Hola,

You can set that in your CPAN config I guess:

% locate Config.pm | grep CPAN

mine is:

/System/Library/Perl/5.8.8/CPAN/Config.pm

jonasbn

On 23/08/2008, at 05.33, WetMogwai wrote:



Re: Can't find Mac::Growl

2008-08-22 Thread David Green
Hi, I am interested in (possibly) using Mac::Growl from Perl.  Have  
you gotten it working and or do you have some pointers for me?


Thanks,

David Green




On 18 Aug, 2008, at 20:22, WetMogwai wrote:


Sorry if this has been discussed before. I searched and didn't see
usable results.

I'm new to Perl and newer to Perl on Mac, but I thought I understood
CPAN and use. I installed Mac::Growl using CPAN from the command line.
I'm using the Perl distro included with Leopard. My program contains
the following lines:

use Mac::Growl ':all';
BEGIN { $Mac::Growl::base = 'Mac::Applescript' }

(I've tried it with the lines reversed with the same results. Just
reaching with no clue.)

I get this error when I run it:

Can't locate Mac/Growl.pm in @INC (@INC contains: /System/Library/ 
Perl/

5.8.8/darwin-thread-multi-2level /System/Library/Perl/5.8.8 /Library/
Perl/5.8.8/darwin-thread-multi-2level /Library/Perl/5.8.8 /Library/
Perl /Network/Library/Perl/5.8.8/darwin-thread-multi-2level /Network/
Library/Perl/5.8.8 /Network/Library/Perl /System/Library/Perl/Extras/
5.8.8/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.8 /
Library/Perl/5.8.6 /Library/Perl/5.8.1/darwin-thread-multi-2level /
Library/Perl/5.8.1 .) at ../bin/pagewatch.pl line 5.
BEGIN failed--compilation aborted at ../bin/pagewatch.pl line 5.

CPAN seems to be writing files to /var/root/perl/lib/perl5/Extras/
5.8.8/, but there isn't anything in /var/root/. I've searched for it
with find and mdfind. I can't find where modules are being installed
and neither can Perl. How can I get CPAN to install to somewhere in
@INC?