I'm having an issue at the moment that I don't understand what is going on as I am very new to Linux.
There is a script that I am trying to run (which I won't post as I don't think I am allowed to) that needs to be run as the root user, but when I run it, it says that it doesn't have the required environment variable and it needs to be set. But the script should do this.
We have it installed on two boxes, one works fine and the other doesn't.
When we run this command on the working box:
su - user -l -c env 2>/dev/null | grep 'ENVVARIABLE=' | awk -F= '{print $2}'
It returns the correct path.
If I run it on the other box it brings back nothing. However if I switch the -l and -l around it brings back the correct path.
Can anybody point me in the right direction as to what is going wrong here? I'm not allowed to just upgrade everything on box to see if that fixes the issue unfortunately. But if I can narrow it down that would help a lot as at the moment I don't have any clue. If you need more information then hopefully I can provide (Although that may have to be next week).
Note: In the actual script the -l isn't there at all:
if [ "$myself" = "root" ]; then
ENVVARIABLE=`su - $user -c env 2>/dev/null | grep 'ENVVARIABLE=' | awk -F= '{print $2}'
fi
Edit 1: The same shell (bash) is used for the users on both boxes
ENVVARIABLE
being set foruser
? Is it in~/.bashrc
or something? Is this the same on both hosts?