bash - 运行带有 su 错误的 shell 脚本
问题描述
我有一个由 root 运行的脚本,看起来像这样
curl -O some stuff
mv it to user guest directory
su - guest -c sh /home/guest/script.sh
一切正常,直到最后一个su
命令。它给了我错误
sh: cannot set terminal process group (-1): inappropriate ioctl for device
sh: no job control in this shell
如何让用户guest
执行script.sh
using su
?
解决方案
来自man su:
概要
su [选项] [-] [用户 [参数...]]
您更改了参数的顺序。试试这个方法:
su -c "/path/to/sh /home/guest/script.sh" - guest
"
注意命令开始之前和结束之后的引号。此外,我建议您也为sh
.
推荐阅读
- javascript - 访问对象内的数据对象属性
- python - 无法在 Python 程序中连接到 MySQL
- laravel - 如何在 html 页面中显示变量 ( key ) 的值?
- r - 未使用参数的 R 错误消息 (writexl)
- python - 动态更新选项菜单 tkinter
- templates - helm 图表模板:如果 value 不存在,则默认为 true
- python - 有没有办法将最大的子集设置为 statsmodels glm 中的基础,以及如何从参数中获取基础?
- arrays - 数组列表到对象数组
- python - PermissionError: [Errno 13] 将 tkinter 用于图像时
- postgresql - 使用函数/过程在 postgresql 中将 IPv4 转换为十六进制