【问题标题】:How do I run a local fish script on a remote server?如何在远程服务器上运行本地鱼脚本?
【发布时间】:2018-03-14 17:44:32
【问题描述】:

使用 ssh 和 bash,可以在远程服务器上运行本地 bash 脚本:

$ ssh user@server "bash -s" -- < ./example.bash "--arg1" "arg2"

(来自unix.stackexchange.com

假设fish安装在远程服务器上,在远程服务器上运行本地fish脚本的等效命令是什么?

【问题讨论】:

    标签: ssh fish remote-execution


    【解决方案1】:

    等效的命令是:

    $ ssh user@host fish -- < ./example.fish --arg1 arg2
    

    在本地演示这一点(没有 ssh,并假设系统有 /dev/stdin 设备):

    $ echo 'set -S argv' | fish -- /dev/stdin --abc def
    $argv: not set in local scope
    $argv: set in global scope, unexported, with 2 elements
    $argv[1]: length=5 value=|--abc|
    $argv[2]: length=3 value=|def|
    $argv: not set in universal scope
    

    或者使用 /dev/fd/0

    【讨论】:

    • 就像你的例子:ssh user@host fish /dev/stdin -- --arg1 arg2 &lt;./example.fish。我的示例只是为了展示解决方案如何工作并正确填充$argv 并运行从标准输入读取的脚本的简化。没有 ssh 的复杂性及其使用引入的任何问题(例如,身份验证失败)。
    猜你喜欢
    • 2013-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多