2

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?

lofidevops
  • 15,528
  • 14
  • 79
  • 119

1 Answers1

3

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.

lofidevops
  • 15,528
  • 14
  • 79
  • 119
Kurtis Rader
  • 6,734
  • 13
  • 20
  • Just like your example: `ssh user@host fish /dev/stdin -- --arg1 arg2 <./example.fish`. My example was just a simplification to show how the solution works and correctly populates `$argv` and runs the script read from stdin. Without the complication of ssh and any problems its use introduces (e.g., authentication failures). – Kurtis Rader Oct 04 '17 at 19:18