Reputation: 21
I'm working on CentOS 7 and regular sudo commands (e.g. sudo yum update, etc.) are working fine. However, one of my sudo commands require to preserve the environment variables, so I used:
sudo -E ./build/unit-tests
and I get this error:
/var/tmp/sclyZMkcN: line 8: -E: command not found
It appears sudo is not recognizing the -E command on CentOS 7. What can I do in this case? Any alternatives or possible fix?
Upvotes: 1
Views: 2827
Reputation: 331
I've recently come across exactly the same problem. I tried to execute a script with sudo -E
, which caused the above-mentioned -E: command not found
error.
The reason turned out to be Red Hat Developer Toolset providing a broken sudo
. A solution is to use the full sudo
system path to make sure a good one is used, i.e.
/usr/bin/sudo -E ./some_script.sh
Upvotes: 3
Reputation: 189387
I you know which variables to preserve, you can use env
to pass them through the command line.
sudo env foo="$foo" bar="$bar" ./build/unit-tests
Upvotes: 0