I have a shell script that I need to run as another user, but, it can only be executed by the current user in my app. I want to execute something like this:
su user2 -C script.sh
But, how can I run this without having to type the password. Say the current user is user1 and the other user is user2. So, I need something which only lets user1 execute the script under user2 and nothing else.
I've tried changing my sudoers file but to no avail. Is there anything that I can do here with which I can accomplish this?