0

Okay, I currently use an eggdrop IRC bot on my server. I want to make a bash script to start it up as well as a few other scripts at the same time. All that's left is to make it start, but it won't run as root.

However, I also need to be in the current directory of the file to run it, or it displays an error.

For example: /home/eggdrop/eggdropbot/eggdrop will display an error, so to run it I need to cd /home/eggdrop/eggdropbot and then ./eggdrop

So I can't just use "sudo -u eggdrop /home/eggdrop/eggdropbot/eggdrop" and as you probably know, sudo won't cd, either, since that would be pointless.

Any suggestions?

3 Answers 3

2

Why not just cd first and then sudo -u ./eggdrop .?

Sign up to request clarification or add additional context in comments.

2 Comments

Because somehow I'm an idiot and didn't think of that. One second let me try it.
Ugh I'm an idiot, worked like a charm. I actually thought of that earlier and I guess I forgot about it. Was trying too hard to make it a bit more simple, I guess. Only managed to make it more difficult. Thanks
1

What about doing the cd, and, only then, launch the command with sudo ?

I suppose something like this should do the trick :

cd /home/eggdrop/eggdropbot && sudo -u eggdrop ./eggdrop

Comments

0

You can cd to the directory as the root user and then use sudo -u to invoke the program from the working directory.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.