Re: Finding the current user
On Jan 5, 2006, at 6:04 PM, Sherm Pendley wrote: If you need more than the numeric user ID, have a look at: perldoc getpwnam perldoc User::pwent D'oh! getpwnam() is a function (not a module), so that should be: perldoc -f getpwnam perldoc User::pwent sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: Finding the current user
On Jan 5, 2006, at 5:53 PM, James Reynolds wrote: I know I can get this with `whoami`, but I was wondering if there was a "Perl" way to find the user who executed the script. I basically want to make it so my script is executable by normal users, but prints an error if it is not only the root user. The $< variable has the real user id, and $> is the effective user id. If you need more than the numeric user ID, have a look at: perldoc getpwnam perldoc User::pwent sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: @INC
On Jan 5, 2006, at 3:41 PM, The Ghost wrote: The other perl was installed by darwinports. It doesn't ask questions. If it did, I wouldn't install it. I'm not concerned about incompatibilities You should be. as the perl versions are so close The versions are close, but the architectures aren't the same. Binary modules will be incompatible. ...I have 2 versions of perl installed and only use one of them. The reason for 2 versions is a port system that refuses to rely on the already installed perl. So I have: /System/Library/Perl/5.8.6/darwin-thread-multi-2level AND /opt/local/lib/perl5/5.8.7/darwin-2level The system default Perl is multi-threaded, but the one installed by DarwinPorts is not. Binary modules compiled for one will not work with the other. That's why there's an architecture-specific subdirectory in the first place - it's not just there to annoy you! :-) If you want scripts that begin with "#!/usr/bin/perl" to use the Perl that's managed by DarwinPorts, you can delete /usr/bin/perl - it's just a link to /usr/bin/perl5.8.6, so you already have a backup. Then replace it with a symbolic link to /opt/local/bin/perl. Like this: sudo rm /usr/bin/perl sudo ln -s /opt/local/bin/perl /usr/bin/perl Note that if you do this, *every* script that begins with "#!/usr/bin/ perl" will be using the DarwinPorts Perl - including the scripts that Apple supplies, which have not been tested and verified with that configuration. As you've said, the difference is small, so problems are very unlikely, but still possible. The safest route is to leave /usr/bin/perl alone, since Apple- supplied scripts don't rely on any external modules anyway, and use "#!/opt/local/bin/perl" in your own scripts, so that they use the DarwinPorts Perl and any modules you've installed for that. sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: @INC
On 2006.1.6, at 05:41 AM, The Ghost wrote: The other perl was installed by darwinports. It doesn't ask questions. If it did, I wouldn't install it. I'm not concerned about incompatibilities as the perl versions are so close. I could reconfigure darwinports, but I don't want to. So this isn't a solution to my issue. I suggest you configure your Darwinports anyway. Thanks though. Ryan On Jan 5, 2006, at 2:01 PM, John Delacour wrote: At 12:15 pm -0600 5/1/06, The Ghost wrote: ...I have 2 versions of perl installed and only use one of them. The reason for 2 versions is a port system that refuses to rely on the already installed perl. So I have: /System/Library/Perl/5.8.6/darwin-thread-multi-2level AND /opt/local/lib/perl5/5.8.7/darwin-2level /opt/local/lib/perl5/5.8.7 ... If you download 5.8.7 and let it install itself in the default location without bothering even to look at the difficult questions, I guess you will solve all you problems and end up with this: @INC: /usr/local/lib/perl5/5.8.7/darwin-2level /usr/local/lib/perl5/5.8.7 /usr/local/lib/perl5/site_perl/5.8.7/darwin-2level /usr/local/lib/perl5/site_perl/5.8.7 /usr/local/lib/perl5/site_perl/5.8.6/darwin-2level /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl Whatever you have in /opt or whatever other non-standard directory can then porbably be safely consigned to the trash. JD
Finding the current user
I know I can get this with `whoami`, but I was wondering if there was a "Perl" way to find the user who executed the script. I basically want to make it so my script is executable by normal users, but prints an error if it is not only the root user. -- Thanks, James Reynolds University of Utah Student Computing Labs [EMAIL PROTECTED] 801-585-9811
Re: @INC
The other perl was installed by darwinports. It doesn't ask questions. If it did, I wouldn't install it. I'm not concerned about incompatibilities as the perl versions are so close. I could reconfigure darwinports, but I don't want to. So this isn't a solution to my issue. Thanks though. Ryan On Jan 5, 2006, at 2:01 PM, John Delacour wrote: At 12:15 pm -0600 5/1/06, The Ghost wrote: ...I have 2 versions of perl installed and only use one of them. The reason for 2 versions is a port system that refuses to rely on the already installed perl. So I have: /System/Library/Perl/5.8.6/darwin-thread-multi-2level AND /opt/local/lib/perl5/5.8.7/darwin-2level /opt/local/lib/perl5/5.8.7 ... If you download 5.8.7 and let it install itself in the default location without bothering even to look at the difficult questions, I guess you will solve all you problems and end up with this: @INC: /usr/local/lib/perl5/5.8.7/darwin-2level /usr/local/lib/perl5/5.8.7 /usr/local/lib/perl5/site_perl/5.8.7/darwin-2level /usr/local/lib/perl5/site_perl/5.8.7 /usr/local/lib/perl5/site_perl/5.8.6/darwin-2level /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl Whatever you have in /opt or whatever other non-standard directory can then porbably be safely consigned to the trash. JD
Re: @INC
At 12:15 pm -0600 5/1/06, The Ghost wrote: ...I have 2 versions of perl installed and only use one of them. The reason for 2 versions is a port system that refuses to rely on the already installed perl. So I have: /System/Library/Perl/5.8.6/darwin-thread-multi-2level AND /opt/local/lib/perl5/5.8.7/darwin-2level /opt/local/lib/perl5/5.8.7 ... If you download 5.8.7 and let it install itself in the default location without bothering even to look at the difficult questions, I guess you will solve all you problems and end up with this: @INC: /usr/local/lib/perl5/5.8.7/darwin-2level /usr/local/lib/perl5/5.8.7 /usr/local/lib/perl5/site_perl/5.8.7/darwin-2level /usr/local/lib/perl5/site_perl/5.8.7 /usr/local/lib/perl5/site_perl/5.8.6/darwin-2level /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl Whatever you have in /opt or whatever other non-standard directory can then porbably be safely consigned to the trash. JD
Re: @INC
At 12:15 -0600 1/5/06, The Ghost wrote: >How can I permanently add to @INC? I have 2 versions of perl installed and >only use one of them. The reason for 2 versions is a port system that >refuses to rely on the already installed perl. Try setting the PERL5LIB environment variable. It's formatted like a $PATH for perl. I set it in $HOME/.MacOSX/environment.plist so that it works when initiated from a Cocoa or Carbon application. You may have a problem with incompatibility of stuff in an @INC area that demands another version of perl. That's why the ports don't attempt to mix things up. -- --> Science is the business of discovering and codifying the rules and methods employed by the Intelligent Designer. Religions provide myths to mollify the anxiety experienced by those who choose not to participate. <--
@INC
How can I permanently add to @INC? I have 2 versions of perl installed and only use one of them. The reason for 2 versions is a port system that refuses to rely on the already installed perl. So I have: $ /usr/bin/perl -e 'print join("\n", @INC)' /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6 /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl /Network/Library/Perl/5.8.6/darwin-thread-multi-2level /Network/Library/Perl/5.8.6 /Network/Library/Perl /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 AND $ /opt/local/bin/perl -e 'print join("\n", @INC)' /opt/local/lib/perl5/5.8.7/darwin-2level /opt/local/lib/perl5/5.8.7 /opt/local/lib/perl5/site_perl/5.8.7/darwin-2level /opt/local/lib/perl5/site_perl/5.8.7 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.7/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.7 /opt/local/lib/perl5/vendor_perl I really only want to use /usr/bin/perl, but the port system will put modules into the /opt/local/bin/perl version which I want to use from /usr/bin/perl. Thanks!