简体   繁体   中英

using fabric to change LD_LIBRARY_PATH

when i login a remote server through ssh, i see the LD_LIBRARY_PATH was :

echo $LD_LIBRARY_PATH
:/usr/local/lib

And when i use fabric in python, to run the same code in fabric run api, the result is empty.

from fabric.api import *
def test():
    run("echo $LD_LIBRARY_PATH")

and even when i try to change the LD_LIBRARY_PATH using fabric, it doesn't work at all.

from fabric.api import *
def test():
    run("echo $LD_LIBRARY_PATH")
    run("export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH")

Does anyone know why?

I had the same problem and here is a way to fix it. You need at least fabric 1.5.4 i think to use shell_env.

with shell_env(LD_LIBRARY_PATH ="/usr/local/lib"):
    run('something')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM