Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: run shell command as another user

by graff (Chancellor)
on Apr 17, 2014 at 02:56 UTC ( #1082583=note: print w/ replies, xml ) Need Help??


in reply to run shell command as another user

Wouldn't it be a lot easier (and safer, and more reliable, and more flexible, and more maintainable, andů) to use DBI, and have your perl script connect directly to the database(s) you want to get information from?

(There are database-driver modules on CPAN for connecting to DB2 databases, so it's just a question of making sure you have the modules you need, and then working out how to "list db directory" using DBI, rather than using shell commands that involve "su" privileges (*shudder*).

(Update: I realize you did mention something about not using modules, but there would have to be some severely compelling reason for not using DBI, especially if the alternative is that you have to use root privileges just to get information from databases.)


Comment on Re: run shell command as another user
Re^2: run shell command as another user
by ox1d0 (Initiate) on Apr 17, 2014 at 16:18 UTC

    Hello graff thanks for the response,

    yes you are right! "Would it be a lot easier." I'm learning about DBI and DBD::DB2 modules. I'll use in some point. My problem now is that I have root access, but i don't have the password for each instance that is the reason because i can't use DBD::DB2 in this point.

    I need to use "su -" or "sudo su -" to get the instance environment and work with the data bases then maybe i can use DBD::DB2.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1082583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (17)
As of 2014-12-19 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (84 votes), past polls