ICPooreman
asked on
su user -c command -args doesn't accept arguments
I'm new with shell scripting so I may be missing something easy. I'm writing a shell script which I want to su to a different user in my case the root user. The problem is that when I do that it takes control away from the script. Basically all I need to do is run one command as the root user so I decided I could write
su root -c ./mycommand args
which doesn't take control away from the script however mycommand now doesn't get the args I pass it. What can I do to fix this???
su root -c ./mycommand args
which doesn't take control away from the script however mycommand now doesn't get the args I pass it. What can I do to fix this???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In fact some su are more restrictive about parameters and requires username as last param, try then
su -c "./mycommand arg arg" root
su -c "./mycommand arg arg" root
sudo ./mycommand args