Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.)

Replies are listed 'Best First'.
Re^2: run shell command as another user
by ox1d0 (Acolyte) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1082583]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-12-15 23:22 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (444 votes). Check out past polls.