我正在運行一個bash腳本sudo并嘗試了以下操作,但使用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`
uj5u.com熱心網友回復:
您可以使用原始用戶,例如:
sudo -u $SUDO_USER aws cp ...
uj5u.com熱心網友回復:
您還可以使用source而不是運行腳本bash-- usingsource將導致腳本在與打開的終端視窗相同的 shell 中運行,這將使相同的 env 保持在一起(例如用戶)-盡管老實說,@Philippe 的答案更好,更正確的一個。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/314515.html
