[英]Is it possible to run bash script what find with the find command with other user?
我试图在目录中找到所有bash脚本,然后我想与其他用户一起运行所有这些脚本。 在bash文件中,我使用的命令只能在otherUser下使用。
我试过这些命令:
sudo -H -u otherUser find . -maxdepth 3 -type f -name '*myBashFile' -execdir {} \;
find . -maxdepth 3 -type f -name sudo -H -u otherUser '*myBashFile' -execdir {} \;
sudo -H -u otherUser bash -c 'find . -maxdepth 3 -type f -executable -name '*myBashFile' -execdir {} \;'
我总是在bash脚本中为自己的命令找到'command not found'。
感谢答案,PATH的事情是关键,这是最终的代码:
#!/usr/bin/env bash
export PATH=$PATH:/path/of/the/command/
echo otherUserPassword | su -c 'find . -maxdepth 3 -type f -executable -name '*myBashFile' -execdir {} \;' otherUser
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.