将变量从 shell 脚本传递到 GNU 屏幕
我有一个如下所示的 Linux shell 脚本:
tron="/home/duke/aa/bin/armagetronad-dedicated"
var="/home/duke/aa/servers/$1/var/"
log="${var}logs/all_console_logs.log"
userconfigdir="${var}customize/config/"
parser="${var}customize/parser-rpg.php"
ladderlog="${var}ladderlog.txt"
cmds="${var}cmd.txt"
screen -S $1 -X kill
screen -d -m -S $1
screen -S $1 -X stuff 'tail -n0 -f -s 0.01 $cmds | (while true; do $tron --userconfigdir $userconfigdir --vardir $var; done) | tee -a $log
'
但是,当使用 stuff
将变量传递到屏幕会话时,它实际上发送“$cmds”而不是 $cmds 内的值。是否也可以将变量带入屏幕会话中?
I have a linux shell script that looks like this:
tron="/home/duke/aa/bin/armagetronad-dedicated"
var="/home/duke/aa/servers/$1/var/"
log="${var}logs/all_console_logs.log"
userconfigdir="${var}customize/config/"
parser="${var}customize/parser-rpg.php"
ladderlog="${var}ladderlog.txt"
cmds="${var}cmd.txt"
screen -S $1 -X kill
screen -d -m -S $1
screen -S $1 -X stuff 'tail -n0 -f -s 0.01 $cmds | (while true; do $tron --userconfigdir $userconfigdir --vardir $var; done) | tee -a $log
'
However, when passing variables to the screen session using stuff
, it's actually sending "$cmds" instead of the value inside $cmds. Is it possible to bring the variables into the screen session too?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单引号抑制变量替换。这对最后一行有用吗?
Single quotes suppresses variable substitution. Will this work instead for the last line?