Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在用 bash 编写一个脚本,它需要执行以下操作:
ssh -q 192.168.0.123 echo $FOO $BAR
我的问题实际上是两个:
如何从调用它的机器传递一个局部变量($FOO)?
$FOO
如何指定远程变量 ( $BAR)?
$BAR
在局部变量周围使用“$localvar”,在远程变量周围使用“$remotevar”,以便您的本地 shell 解释(“$localvar”)或不解释(“$remotevar”)相应的变量。
所以
ssh -q 127.0.0.123 echo "$FOO" '$BAR'
(你知道 127.0.0.0/8 是你的本地机器,呵呵?^^)