14
2
Is there a way to run a command "as if" it is in a new login session?
I've already tried env -i
. However, I don't want to deal with various ENV variables I have to set or unset.
I've also tried bash -c "some command"
and bash -l -c "some commmand"
, but they all copy the current environment.
The closest I have come is a ghetto solution: ssh me@localhost "some command"
Use
/bin/bash --login
to get that behavior. I use it e.g. to get a proper$PATH
. – Daniel Beck – 2011-08-04T14:50:40.180That is the equivalent of
/bin/bash --l
, which I already tried. It copies the original environment. Try it:export SOME_VAL=something
. Then/bin/bash --login
. Thenenv | grep SOME_VAL
. The value will be there. – dgo.a – 2011-08-04T15:03:29.670