Python fabric 没有在本地执行脚本

Python fabric is not executng script locally

我正在尝试在我的本地计算机上执行 bash 脚本。脚本的位置是/opt/saas/script.sh。下面是执行脚本的函数。

# Run script on local machine.
def run_local_script(self, path, script):
    print("Path:"+path)
    with cd(path):
        local('.' + script)

但每次我 运行 这个,我都会得到这个。

Path is: /opt/saas/
[localhost] local: ./update_services.sh
/bin/sh: 1: ./update_services.sh: not found

Fatal error: local() encountered an error (return code 127) while executing './update_services.sh'

Aborting.

注意:我正在尝试 运行在本地使用与远程计算机建立的先前连接编写脚本。我希望那应该不会影响。我也试过 运行 disconnect_all() 之后的脚本,但还是没有成功。

改为使用 lcd 上下文管理器(参见 Note)。

# Run script on local machine.
def run_local_script(self, path, script):
    print("Path:"+path)
    with lcd(path):
        local('.' + script)