carlspring
carlspring

Reputation: 32697

Variables over ssh

I am writing a script in bash which needs to do things like:

ssh -q 192.168.0.123 echo $FOO $BAR

My questions are in fact two:

Upvotes: 2

Views: 1072

Answers (1)

Olivier Dulac
Olivier Dulac

Reputation: 3801

use "$localvar" around local variables and '$remotevar' around remote ones, so that your local shell interpret ("$localvar") or does not interpret ('$remotevar') the variable accordingly.

so

ssh -q 127.0.0.123 echo "$FOO" '$BAR'

(you do know that 127.0.0.0/8 is your local machine, heh? ^^)

Upvotes: 2

Related Questions