I am trying to run a script as another user, with the user's
.bashrc properly loaded (it is a python script and it relies on
$PYTHONPATH being properly set).
I tried everything I found for example here, but the best I could coax out of the system was an empty
$PYTHONPATH (which is better than my original, where it actually used my
The usecase is that I'm teaching students about shebangs and paths and whatnot, and I wanted an automated way of checking whether their script are ok or not. I can check them by dropping into their envs with
sudo su <username>, but that is very tedious.
How can I execute a script as another user, with their environment loaded the same as if I used
sudo su <username> and then ran it myself?