sshfishremote-execution

How do I run a local fish script on a remote server?


With ssh and bash, it is possible to run a local bash script on a remote server:

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

(from unix.stackexchange.com)

Assuming fish is installed on the remote server, what is the equivalent command to run a local fish script on a remote server?


Solution

  • The equivalent command would be:

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

    To demonstrate this locally (without ssh, and assuming the system has the /dev/stdin device):

    $ 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
    

    Alternatively use /dev/fd/0.