I am trying to just do a simple echo $MYVAR on a remote server with Fabric.
The environment variable is in my ~/.bashrc file on the remote host.
I have tried:
run("source /home/<myusername>/.bashrc && echo $MYVAR")
This just prints an empty string. Running it when logged in on the remote machine prints "5", the value in the bashrc file. Does anyone know why this would be?
I need the environment variable to be set from a file on the remote host, and not decided by Fabric.
I am running the ssh commands as <myusername>
, so the username seems correct. This seems like a duplicate of this question, except that maybe they were running things as the wrong user. I also tried the shell
argument to run
, with no luck.
I haven't tried the various context manager-ish things, as they just seem to be a shorthand for command1 && command2.