Bash eval 包含在引号内
我有一个 bash 脚本,它采用一个参数并执行如下操作:
ssh -t someserver "setenv DISPLAY $1; /usr/bin/someprogram"
如何强制 bash 替换 $1 而不是传递文字字符“$1”作为显示变量?
I have a bash script which takes one parameter and does something like this:
ssh -t someserver "setenv DISPLAY $1; /usr/bin/someprogram"
How can I force bash to substitute in the $1 instead of passing the literal characters "$1" as the display variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您对 sehe 答案的评论,听起来您只是希望远程命令使用本地 X 显示 - 以便该程序在您的远程服务器 (
someserver
) 上运行,但显示在计算机上您运行了 ssh 命令。这可以通过仅传递
-X
来完成,例如由于某种原因,这不适用于某些程序,例如
evince
。我不太确定为什么。我非常确定evince
是我在通过 SSH 连接转发时遇到问题的唯一应用程序。如果这不是您想要做的,请解释一下。
Based on your comment on sehe's answer, it sounds like you just want the remote command to use the local X display — so that the program is running on your remote server (
someserver
) but being displayed on the machine you ran thessh
command on.This can be done by just passing
-X
, e.g.For some reason, this doesn't work with a few programs, for example
evince
. I'm not really sure why. I'm pretty sure thatevince
is the only app I've had trouble forwarding back over an SSH connection.If this isn't what you're aiming to do, please explain.
编辑 您是否知道
哪些已经支持开箱即用的 X 转发?另请注意
是否需要增加“来宾”的权限。
如果你想转发非标准的X显示地址,你总是可以使用
Bonus:身份验证后使ssh后台,添加'-f'
本地什么?这应该已经可以如图所示工作了。远程?转义 $:
\$
但是,我不确定该命令将从哪里获取其参数 ($1)
Edit Are you aware of
which already support X forwarding out of the box? Also look at
in case you need to increase permissions to 'guests'.
If you want to forward non-standard X display address, you could always use
Bonus: to make ssh background after authentication, add '-f'
What locally? That should already work as shown. Remotely? escape the $:
\$
However, I'm not sure where the command would be taking it's arguments ($1) from