LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   anyone Perl guru?? (https://www.linuxquestions.org/questions/programming-9/anyone-perl-guru-601863/)

rimvydazas 11-23-2007 06:51 AM

anyone Perl guru??
 
I just installed Perl and DBI on my Suse box. When I test my DBI (perl -e 'use DBI;') from command line using regular account I get this message:

Code:

cdruser1@cdr1:~> perl -e 'use DBI;'
Can't locate loadable object for module DBI in @INC (@INC contains: /usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/DBI.pm line 266
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/DBI.pm line 266.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

However, the same command run as root works just fine. I assume that this is file permissions problems, isn't it? cdruser1 belongs to "users" group and permissions for DBI.pm file reads like that:

cdruser1@cdr1:/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi> la
total 309
drwxr-xr-x 8 root root 312 2007-11-28 12:29 .
drwxr-xr-x 3 root root 88 2007-10-17 16:12 ..
drwx------ 4 root root 96 2007-11-28 12:29 auto
drwx------ 2 root root 72 2007-11-28 12:27 Bundle
drwx------ 3 root root 104 2007-11-28 12:29 Date
drwx------ 3 root root 256 2007-11-28 12:27 DBD
drwx------ 8 root root 536 2007-11-28 12:27 DBI
-r--r--r-- 1 root root 289975 2007-10-16 08:42 DBI.pm
-r--r--r-- 1 root root 1533 2007-07-16 07:04 dbixs_rev.pl
-r--r--r-- 1 root root 15161 2005-03-25 15:57 Roadmap.pod
-r--r--r-- 1 root root 1048 2006-09-04 17:33 TASKS.pod
drwx------ 2 root root 80 2007-11-28 12:27 Win32

Any ideas what would fix the problem? change file permissions, or primary group for cdruser1? any ideas are appreciated. Thanks

terrio 11-23-2007 08:03 AM

I think you just answered your own question.
Quote:

However, the same command run as root works just fine. I assume that this is file permissions problems, isn't it?
Yes it is, change the permissions on the file so that your user (cdruser1) is able to read the file. Currently the user and group permissions are both set to root.

So as root, use chown to change the owner to cdruser1. or chgrp to give a group that cdruser1 is in permission to read the file.

Here is info on chown - http://en.wikipedia.org/wiki/Chown
Here is info on chgrp - http://en.wikipedia.org/wiki/Chgrp
Here is some info on another command to alter the read/write/execute permissions on a file - http://en.wikipedia.org/wiki/Chmod

rimvydazas 11-23-2007 08:57 AM

Quote:

Originally Posted by terrio (Post 2968390)
I think you just answered your own question.


Yes it is, change the permissions on the file so that your user (cdruser1) is able to read the file. Currently the user and group permissions are both set to root.

So as root, use chown to change the owner to cdruser1. or chgrp to give a group that cdruser1 is in permission to read the file.

Here is info on chown - http://en.wikipedia.org/wiki/Chown
Here is info on chgrp - http://en.wikipedia.org/wiki/Chgrp
Here is some info on another command to alter the read/write/execute permissions on a file - http://en.wikipedia.org/wiki/Chmod

Thank you for fast reply. I tried doing something else before your suggestion, and I am surprised that it didn't work. I added cdruser1 to wheel group and enabled %wheel ALL=(ALL) ALL in sudoers file. But I still got the same error. Anyway, about permissions of DBI.pm. As soon as I changed the owner, the DBI test worked out fine. But I still have question. When you look at the permissions -r--r--r-- 1 root root 289975 2007-10-16 08:42 DBI.pm, why cdruser1 can't read DBI.pm during the test if "others" do have read permission. Does DBI.pm must be executed, but not just read? Thanks for your help.

Oh, another weird problem. Maybe someone will know that. I exported two variables in /etc/profile:
Code:

export ORACLE_HOME=/home/cdruser1/cdr/orcl_root
export LD_LIBRARY_PATH=/home/cdruser1/cdr/orcl_root/lib

When I login as cdruser1, both variables exit. When I "su" to root, LD_LIBRARY_PATH just disappears even though ORACLE_HOME still works. Switching back to cdruser1 with "su" doesn't solve the problem; LD_LIBRARY_PATH still doesn't work. Again, after reboot everything works just fine until the first "su". Does it have something to do with wrong file for loading variables? But I still don't get how only one of those variables disappears... Unless there is some other place where ORACLE_HOME is exported. By the way, I use TWM (tab windows manager) if that makes any difference...

Alien_Hominid 11-23-2007 11:36 AM

When you su, you don't take root environment variables (user environment variables are preserved). You need to use su - or sudo -s so user environment variables will be read from his .bash_profile or .bashrc. To exit from the user (in this case root) environment to your normal account just type exit or logout.

Tinkster 11-23-2007 01:09 PM

Code:

drwx------ 4 root root 96 2007-11-28 12:29 auto
drwx------ 2 root root 72 2007-11-28 12:27 Bundle
drwx------ 3 root root 104 2007-11-28 12:29 Date
drwx------ 3 root root 256 2007-11-28 12:27 DBD
drwx------ 8 root root 536 2007-11-28 12:27 DBI

Really, those should all have
Code:

drwxr-xr-x
permissions ...



Cheers,
Tink

rimvydazas 11-25-2007 03:33 AM

Quote:

Originally Posted by Tinkster (Post 2968633)
Code:

drwx------ 4 root root 96 2007-11-28 12:29 auto
drwx------ 2 root root 72 2007-11-28 12:27 Bundle
drwx------ 3 root root 104 2007-11-28 12:29 Date
drwx------ 3 root root 256 2007-11-28 12:27 DBD
drwx------ 8 root root 536 2007-11-28 12:27 DBI

Really, those should all have
Code:

drwxr-xr-x
permissions ...



Cheers,
Tink

all I did I changed the owner for all files and folders in perl directory to my regular user. I assume it should work in this way.

Tinkster 11-25-2007 10:51 AM

Quote:

Originally Posted by rimvydazas (Post 2969929)
all I did I changed the owner for all files and folders in perl directory to my regular user. I assume it should work in this way.

Errrh. It's going to work for this one user. Should there be
any system tasks that require these they may fail. Bad move.

I recommend you read a chapter or two on Linux file-systems,
ownerships and permissions.


Cheers,
Tink

bigearsbilly 11-26-2007 03:08 AM

how did you install?

it seems odd that the file permissions are so pants.
the last thing you want is them to be root only.

personally I would just uninstall and reinstall them using your distro
package manager.

rimvydazas 11-26-2007 03:34 AM

Quote:

Originally Posted by Tinkster (Post 2970218)
Errrh. It's going to work for this one user. Should there be
any system tasks that require these they may fail. Bad move.

I recommend you read a chapter or two on Linux file-systems,
ownerships and permissions.


Cheers,
Tink

Since my PC is dedicated for one task only, there is no any other users to run Perl, which is I would say not bad, but even better move considering security. In addition, I've read all the chapters necessary before I got linux+ certified.

rimvydazas 11-26-2007 03:38 AM

Quote:

Originally Posted by bigearsbilly (Post 2970871)
how did you install?

it seems odd that the file permissions are so pants.
the last thing you want is them to be root only.

personally I would just uninstall and reinstall them using your distro
package manager.

I installed perl through yast, and all other modules from tarballs. Anyway, since changing owner seemed to work, I should be fine because I have only this user in addition to root. Thanks for reply though.

Tinkster 11-26-2007 11:13 AM

Quote:

Originally Posted by rimvydazas (Post 2970894)
Since my PC is dedicated for one task only, there is no any other users to run Perl, which is I would say not bad, but even better move considering security. In addition, I've read all the chapters necessary before I got linux+ certified.

Awesome ... and you understood them, too? :}
I don't mean memorised.


Cheers,
Tink

rimvydazas 11-27-2007 03:27 AM

Quote:

Originally Posted by Tinkster (Post 2971264)
Awesome ... and you understood them, too? :}
I don't mean memorised.


Cheers,
Tink

:rolleyes:

Tinkster 11-27-2007 01:27 PM

Quote:

Originally Posted by rimvydazas (Post 2971967)
:rolleyes:

No ... :/



Cheers,
Tink

rimvydazas 11-28-2007 01:09 PM

Thank you for you all ;) It's good to find a place where people can help :) It's time to read some chapters now ... :study: :D

sundialsvcs 11-30-2007 09:53 PM

Actually, it probably isn't a permissions-problem: it is more likely to be the case that Perl cannot find the libraries that you intend to use.

The '@INC' array is where Perl looks. Such things as the PERL5LIB environment-variable, the use lib pragma, and the original list hard-coded into Perl when it was compiled, can all affect that list.


All times are GMT -5. The time now is 04:12 PM.