On 7/9/07, Lakshmi Sailaja <[EMAIL PROTECTED]> wrote:

It is not a single command that I am supposed to run. I have to change to a
different user and run a couple of commands.

Well, you could use sudo to launch a shell, such as /bin/sh or csh or
bash, and then use that shell to run commands. But it's probably
easier to write a small program (a shell script or even a Perl
program) and simply run that as the other user.

But as per your solution, I would be running one specific command. Also
where am I passing the password in the sudo command?

If you use sudo's -S option, you'll be able to pass the password in
via sudo's STDIN. Check your sudo manpage for the full story.

Password will be figured on the fly so I can't store it in a file.

Huh? You mean you have a small function (of zero parameters) which
outputs the password? That doesn't make much sense. You've got to look
into SOME file (even if it's your program's own file) to find a
password.

In the end, it doesn't matter where the password comes from, as long
as it can go to sudo at the right time. But keeping the credentials in
a file (and having the proper permissions on that file) is the usual
way that people solve this problem. So I'm a little suspicious of any
other solution.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to