Re: location of 'com.apple.versioner.perl'
On Fri, Jul 9, 2010 at 6:39 AM, Alan Fry a...@afco.demon.co.uk wrote: However for the life of me I cannot find the file 'com.apple.versioner.perl.plist' on that machine. It is not in /Library/Preferences. What am I missing? Did you also look under ~/Library/Preferences? -packy -- Packy Anderson Email: packyander...@gmail.com GVoice: (646) 833-8832
Re: perl modules installation on OSX
Oh, decidedly via the CPAN shell. Unless you don't have a compiler loaded on your system... On Tue, Feb 16, 2010 at 1:29 PM, Noah noah-l...@enabled.com wrote: Hi there, what is the most recommended way to install perl modules on OSX? directly from CPAN via perl or shall I install them from MACports? Cheers, Noah -- Packy Anderson Email: packyander...@gmail.com GVoice: (646) 833-8832
Re: Perl install problems OSX 10.4.11
OS X 10.4 shipped with 5.8.6, which is what he has. I think some of the misunderstanding is from Terrence's inexperience with perl. Terrence, the modules you're missing aren't missing because you don't have a full version of perl. They're probably missing because they weren't included in the base distribution of perl for version 5.8.6. One of perl's great strengths as a programming language is that there is a library of modules called the Comprehensive Perl Archive Network (CPAN, for short) that allows programmers to build on the efforts of others without having to re-invent the wheel. The modules you're missing are modules to do things like build HTML documents and communicate via web protocols. Anyway, from time to time, modules are added to the base install, so there are modules that come standard with 5.8.8 and 5.10.1 that weren't standard with 15.8.6. It may also be that Apple decides to add modules to the perl it's delivering with OS X. Anyway, none of this is really a problem, since you can install the modules you need, and things should just work. Here's some commands that will help you: $ head -1 get_iplayer This will tell you which perl of yours the iplayer is using. The one I'm using says /usr/bin/perl, but you may have modified yours. $ which perl This shows you which perl you're using by default. If it shows the same perl as the one iplayer is using, you don't need to type the full path when referring to perl when you want to add modules. $ sudo /usr/bin/perl -MCPAN -e shell This will run the CPAN shell, which will allow you to install modules in the library used by /usr/bin/perl. If you're using a different perl than that one, use that path. cpan install LWP cpan install Fcntl cpan install HTML cpan install HTTP These commands tell the CPAN shell to install those modules. Again, I don't think you're going to solve your problem under OS X 10.4 Tiger without installing the modules you're missing, because I don't think your problem is that you don't have a full version of perl. I think the problem is that Apple decided to add optional modules to 10.5 that they hadn't added to 10.4 and aren't part of the base perl install. You can easily add these modules through the CPAN shell, however, so your solution should probably be that. Or upgrade to OS X 10.5. I did that this past weekend to my G4 Powerbook. Yes, I know I'm a full rev behind, but better late than never. -packy On Sep 14, 2009, at 8:04 AM, Mine wrote: Hi, Thank you for the very informative response Alan. I think the problem is probably to do with my Perl install. I looked in /System/Library/Perl/ but the Perl folder contained 5.8.6 not 5.8.8. I could not find any of the following: Fcntl HTML HTTP LWP I previously installed some applications using MacPorts, and it appears that there is an install of Perl 5.8.8 in /opt/local/bin/. Over the weekend still trying to solve the problem I also installed Perl 5.10.1 in an attempt to upgrade my system Perl install. That is in /usr/local/bin/. I also searched /usr/local/lib/perl5/5.10.1/ and /opt/local/lib/ perl5/5.8.8/ and it would appear that the MacPorts install is the most complete but I could not find an LWP directory or HTTP, and I was not sure where to look for URI. The HTML directory contained entities.pm, and headerParser.pm but no Cookies Is it possible to upgrade the system Perl install to a full version of Perl 5.8.8? Thanks, Terrence On 14 Sep 2009, at 11:09, Alan Fry wrote: On 13 Sep 2009, at 03:46, Doug McNutt wrote: At 23:22 +0100 9/12/09, Mine wrote: Hi, Thanks for your excellent response, makes installing so easy assuming I did it correctly. I think everything that was required is installed, but I am not sure everything was installed in the right location. It appears that Perl 5.10.1 was installed and all the modules I installed are associated with Perl 5.10.1. When I try to run the get_iplayer PVR module I get the following error: Can't locate loadable object for module HTML::Parser in @INC (@INC contains: /opt/local/lib/perl5/5.8.8/darwin-2level (I have abbreviated the error message) And when I enter perl -v I get the following: This is perl, v5.8.8 built for darwin-2level So the system does not see the Perl 5.10.1 install. Can someone please tell me if there is a was to install the modules so they relate to perl, v5.8.8, or point get_iplayer to use Perl 5.10.1. I suspect that Apple's perl is 5.8.8 and it is installed in /usr/ bin. It needs to stay there because Apple's updates may depend on it. Installing 5.10.1 in /usr/bin/ replacing 5.8.8 is not recommended. I also suspect that perl 5.10 is installed in /usr/local/bin but that might be different like /opt/bin depending on just how you installed it.. Look around for it. /opt/local/lib/ sounds unlikely to me. You are probably
Re: Perl install problems OSX 10.4.11
On Sep 11, 2009, at 5:33 PM, Mine wrote: I don't fully understand what Perl does but if Perl comes installed with OSX it appears that I also have an install of Perl via MacPorts. I assume that get_iplayer is looking at the preinstalled Perl but I am not sure. Perl is a programming language, and it appears that get_iplayer is written in it. The perl that comes installed with OS X is located at /usr/bin/perl. If you've also installed perl from some other source (like MacPorts) then you might have another perl at some other location. I've taken a look at the iplayer source (available through http:// linuxcentre.net/getiplayer/) and it's definitely using the Perl that comes with OS X at /usr/bin/perl/ Although I am no expert, I have used the Terminal to install binaries before so i will give it a go. It's fairly simple. Type sudo perl -MCPAN -e shell At a Terminal prompt and enter in your password when prompted. You'll be asked to configure CPAN the first time you run it; just take the defaults and you'll be fine. Then, once you get a cpan[1] command prompt, type the following: cpan[1] install LWP and hit enter. It will automatically figure out what prerequisites you need and download all the packages. Again, I generally take the defaults and everything works well. -packy
Re: How to run Perl script at Mac OS (Darwin) Release?
On Mar 9, 2008, at 11:12 AM, Doug McNutt wrote: Hashing of tools by shells has not been mentioned. It may not be part of the problem but on invocation many, if not all, shells examine the $PATH variable and make a table of executables that it finds. The table is then converted to a hashed lookup array in order to improve speed of response. (That probably makes little sense today but it was started during the days of mag tape.) So if you create a perl script, place it somewhere in $PATH, and set its execute permission a running shell will not find it. A full path, perhaps starting with the current directory . always works. In tcsh the command to rework the hash of tools is rehash. Restarting the shell with a new Terminal.app window will do pretty much the same thing. It's not likely that Gary is having problems with his shell creating a hash table of executables on startup; he's using bash (the default in OS X these days), and bash doesn't do that: test1.pl -bash: test1.pl: command not found If he had created test1.pl in a directory in his path (say, /Users/ gary/bin) but the executable bit wasn't set, he'd have gotten the error -bash: /Users/gary/bin/test1.pl: Permission denied even if the file was created after his bash shell started. If he then had the executable bit set properly (chmod +x test1.pl) and didn't have a perl installed at /usr/local/ActivePerl-5.10/bin/perl, he'd have gotten the error -bash: /Users/gary/bin/test1.pl: /usr/local/ActivePerl-5.10/bin/perl: bad interpreter: No such file or directory Of course, maybe he's eschewing the default perl on OS X because he wants to use the 5.10 for some reason and he downloaded ActiveState's build for OS X; if that's the case, then that's probably the shebang line he wants. Anyway, I'll shut up now, since people have just about beat this subject to death. ;) Here's hoping Gary's happily programming perl on his Mac now... -packy -- Packy Anderson [EMAIL PROTECTED] If I had a boat, I'd go out on the ocean; And if I had a pony, I'd ride him on my boat. We could both together go out on the ocean-- Me upon my pony on my boat.
Re: Perl Module Installation in $HOME
On Aug 24, 2006, at 5:04 PM, Doug McNutt wrote: I guess I wasn't clear. I want the modules installed in my $HOME directory so that they won't 1) Get lost when a newer OS gets installed - especially with Linux. 2) Get in the way of someone else's, the main geek - my wife's, idea of what should be there. What you're looking for is http://search.cpan.org/~andk/CPAN-1.87/lib/ CPAN.pm#5 : I am not root, how can I install a module in a personal directory? First of all, you will want to use your own configuration, not the one that your root user installed. If you do not have permission to write in the cpan directory that root has configured, you will be asked if you want to create your own config. Answering yes will bring you into CPAN's configuration stage, using the system config for all defaults except things that have to do with CPAN's work directory, saving your choices to your MyConfig.pm file. You can also manually initiate this process with the following command: % perl -MCPAN -e 'mkmyconfig' or by running mkmyconfig from the CPAN shell. You will most probably also want to configure something like this: o conf makepl_arg LIB=~/myperl/lib \ INSTALLMAN1DIR=~/myperl/man/man1 \ INSTALLMAN3DIR=~/myperl/man/man3 You can make this setting permanent like all o conf settings with o conf commit. You will have to add ~/myperl/man to the MANPATH environment variable and also tell your perl programs to look into ~/myperl/ lib, e.g. by including use lib $ENV{HOME}/myperl/lib; or setting the PERL5LIB environment variable. While we're speaking about $ENV{HOME}, it might be worth mentioning, that for Windows we use the File::HomeDir module that provides an equivalent to the concept of the home directory on Unix. Another thing you should bear in mind is that the UNINST parameter can be dangerous when you are installing into a private area because you might accidentally remove modules that other people depend on that are not using the private area. -- Packy Anderson [EMAIL PROTECTED] La perfection est atteinte non quand il ne reste rien ‡ ajouter, mais quand il ne reste rien ‡ enlever. (You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away.) --Antoine de Saint- Exupery
Re: How a file gets copied remotely
On Aug 3, 2006, at 1:22 AM, David Ledger wrote: If M1 copies the file from M2 to M3 then the data comes all the way to M1 and all the way back. That would be the case if M1 used scp to copy from M2 to M3, but that's not what Ted described. M1 makes an ssh connection to M2. Then, on M2, it mounts M3 and uses cp to copy a file from M2 to M3. All the data is moving between M2 and M3; the only information that's moving between M2 and M1 is a shell session. Think of it this way: from a shell on M1, you manually ssh into M2. You then type mount the M3 service, and copy a file to it. None of the data's flowing through your ssh session; it's all happening on the box you're ssh-ed into. -packy -- Packy Anderson [EMAIL PROTECTED] On the internet, no one knows you're a CHICKEN! A GIANT CHICKEN!
Re: How to get a pid
On Jul 31, 2006, at 5:35 PM, Ted Zeng wrote: I don't know how the OS generate the pid for a process. That is why I don't feel comfortable with what I did. The way I understand it, the OS assigns the next highest available pid when creating a process. However, pids wrap around when they reach the maximum defined pid. So, if your process' pid is near the max, your child could get a lower pid. What you want to do is find the pid of your child's child. There's probably a system call you can make to find these things, but I don't know it. What I do know is how to use ps -j or ps -l. I've whipped up the following script to demonstrate the technique. Note: the script you're waiting on may have spawned off children of it's own, so it'd be a good idea to find them and kill them first. This, of course, may let the script spawn off even more processes... start demo script #!/usr/bin/perl use POSIX qw(:sys_wait_h); # need this to get non-blocking waitchild $|=1; # autoflush on unless (defined($kid_pid = fork())) { die Cannot fork: $!; } if ($kid_pid == 0) { # we're running as the child process execNightshade(); } else { print Watching child $kid_pid...\n; my $count=0; my $tConstant = 1; ## I'm impatient do { print Sleeping ... ; sleep 10; $count++; $kid = waitpid($kid_pid, WNOHANG); print kid: $kid_pid, waitpid: $kid\n; } until ($kid 0 or $count $tConstant); if ($count $tConstant ) { recursive_kill($kid_pid); } } sub execNightshade { # since we don't know what execEggplant does beside exec-ing shell # scripts with ``, let's make something up... my $count = join q{ }, 1 .. 10; # make a string '1 2 3 4 5 6 7 8 9 10' # this shell script prints numbers from 1 to 100, sleeping 10 # seconds between each number... my $output = `for i in $count; do echo \$i; sleep 10; done`; # what good is output if we don't use it? print $output\n; } sub recursive_kill { my($pid) = @_; while (my $child = child_pid($pid)) { # kill all its children, grandchildren, etc... recursive_kill($child); } # then kill the process itself print Killing $pid\n; kill 9, $pid; } sub child_pid { my($parent) = @_; # we want to know the process id of the child that's been forked # by our own child. since OS X is a unix, we can use ps to find # it. the following highly non-portable code should work on OS X # and _maybe_ some other unices, but definately won't work on # WinAnything or other, stranger OSes... my $grandkid_pid; open my $ps, ps -l |; while ($ps) { # unless the first field is numeric, we're looking at the # column headings. let's discard it. next unless /^ \s* \d+ /msx; # split /PATTERN/,EXPR,LIMIT # # If EXPR is omitted, splits the $_ string. If PATTERN is # also omitted, splits on whitespace (after skipping any # leading whitespace). # # As a special case, specifying a PATTERN of space (' ') # will split on white space just as split with no # arguments does. my($uid, $pid, $ppid, $other_fields) = split q{ }, $_, 4; # if the process' parent pid isn't our kid's pid, we're # not interested in it next unless ($ppid == $parent); # congratulations! you're a parent! return $pid; } return; # if there's no child, just return } end demo script Sample output: $ pid_test.pl Watching child 7718... Sleeping ... kid: 7718, waitpid: 0 Sleeping ... kid: 7718, waitpid: 0 Killing 7724 Killing 7729 Killing 7733 Killing 7736 Killing 7739 Killing 7742 Killing 7745 Killing 7748 Killing 7751 1 2 3 4 5 6 7 8 9 10 Killing 7719 Killing 7718 $ What's happening is the script is killing the 'sleep', and then before the subroutine can return and kill off the for loop, it's sleeping again. Fortunately, it disposes of the sleeps fairly quickly, and the child process actually returns its data before it gets killed. -- Packy Anderson [EMAIL PROTECTED] Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.