Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using AIX 5.3 with sudo 1.6.9p23. Sudoers file grants user fcomartin permission to run any command as user oas:

fcomarti   ALL=(oas) ALL

User oas has a bash script called menu, which launches other scripts depending on the selected option.

The problem is that some of the secondary scripts redirect standard output to text file temp which is owned by oas user. When this happens the system tells me that user does not have the right permissions to write.

User fcomarti uses ksh, the used command is as follows:

sudo -u oas bash menu

(bash because user oas uses bash).

Menu starts and then menu launches monitorAv script. Inside monitorAv is the line echo > temp; it then errors saying user fcomarti does not have the right permissions to write.

How can I resolve this?

share|improve this question
add comment

2 Answers

Edit that script, don't run sudo something > here, use it like this sudo sh -c "something > here"

man can be quiet useful, search for redirection in man sudo.

share|improve this answer
    
Thanks for the answer, i can't edit the scripts owned by user oas, the problem as i see it is that the secondary scripts launched by menu wont inherit the right permissions. –  carlos.mejia Nov 14 '12 at 18:49
    
Did you try sudo -u oas bash -c "menu"? –  week Nov 14 '12 at 19:03
    
Yes i have used that syntaxis, it keeps telling me: temp: The file access permissions do not allow the specified action. –  carlos.mejia Nov 14 '12 at 19:08
    
You may try to use groups and whoami before that echo. To find out what user execs it. Which permissions are on the file temp. –  week Nov 14 '12 at 19:15
add comment
up vote -1 down vote accepted

I've finally solved the problem, the sintaxis of sudo is as follows:

sudo -u oas bash -c "cd /Oas/bin; menu"

This is because some of the secondary scripts launched by menu, needs an absolute route to work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.