0

Two scenarios here.

Sudo rights are given for a particular group.

a. A new user is created and is assigned to the group. b. Using this user, when we execute commands via shell script it is unable to execute any of the commands (eg., mkdir), it displays 'command not found' error. but

a. When same command is executed in an open terminal it does execute and creates directories. Any idea about the same would be greatly helpful.

Let me know if you need more information on this.

  • Why do you mention sudo? Sounds like a problem with the PATH to me. – strugee Oct 25 '13 at 6:59
1

Try adding the full path to the binary in your script; execute it with: /bin/mkdir You can find the full paths to commands using which followed by the command. It will then return the full path of the command e.g:

$ which mkdir
/bin/mkdir

You could also set PATH for the environment in which the script is run by using export. To do this in the script add a line similar to this: export PATH=$PATH:/bin:/usr/bin:/path/to/whateverelse in the beginning of your script.

See http://www.cyberciti.biz/faq/unix-linux-adding-path/ for details.

Personally I would recommend just using the full path to binaries though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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