Search code examples
sshfish

Fish script for running commands on remote server


If I use a sh script, I get this code.

ssh user@host <<-'ENDSSH'
    #command 1
    #command 2
ENDSSH

What's the analogue in fish?


Solution

  • fish does not have heredocs (see https://fishshell.com/docs/current/design.html)

    echo '#command 1
    #command 2' | ssh user@host
    

    or

    set commands \
        "command 1" \
        "command 2"
    
    printf "%s\n" $commands | ssh user@host