Strange one...
I have a shell script (bash) that I am sending to "at" to run at a future time. That script needs to be run as another user. I've been experimenting with sudo but I need to pass it a password. My trial format is:
sudo -u other_user -A /tmp/pwdfile scriptname.sh parameter(s)
My research shows that the -u option specifies the username to run the task as and the -A option the file to where sysin can be found.
To pass this to "at" my command actually looks like this:
echo "sudo -u other_user -A /tmp/pwdfile script.sh params \" | at hh:mm"
Of course, without the sudo stuff the above command works but the username is incorrect and it causes permission problems.
So I am wondering if anyone has done this before and would be willing to share their technique?
Thanks all.
I have a shell script (bash) that I am sending to "at" to run at a future time. That script needs to be run as another user. I've been experimenting with sudo but I need to pass it a password. My trial format is:
sudo -u other_user -A /tmp/pwdfile scriptname.sh parameter(s)
My research shows that the -u option specifies the username to run the task as and the -A option the file to where sysin can be found.
To pass this to "at" my command actually looks like this:
echo "sudo -u other_user -A /tmp/pwdfile script.sh params \" | at hh:mm"
Of course, without the sudo stuff the above command works but the username is incorrect and it causes permission problems.
So I am wondering if anyone has done this before and would be willing to share their technique?
Thanks all.