我正在运行sudo
的bash
脚本,并尝试了下面,但使用aws cp
得到下面的错误。我认为问题是脚本正在寻找config
/root
中并不存在。然而-E
不是保留了原来的位置吗?是否有一个选项可以与aws cp
一起使用来传递config
的位置?谢谢。
sudo -E bash /path/to/.sh
- inside of this script is `aws cp`
误差
The config profile (name) could not be found
I have also tried `export` the name profile and `source` the path to the `config`
可以使用原用户:
sudo -u $SUDO_USER aws cp ...
您也可以使用source
而不是bash
来运行脚本——使用source
将导致脚本在与您打开的终端窗口相同的shell中运行,这将保持相同的环境在一起(例如user) -尽管老实说,@Philippe答案是更好,更正确的。