dukevin
dukevin

Reputation: 23178

Passing variables from a shell script to a GNU screen

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?

Upvotes: 3

Views: 3506

Answers (1)

King Skippus
King Skippus

Reputation: 3826

Single quotes suppresses variable substitution. Will this work instead for the last line?

screen -S $1 -X stuff "tail -n0 -f -s 0.01 $cmds | (while true; do $tron --userconfigdir $userconfigdir --vardir $var; done) | tee -a $log"

Upvotes: 3

Related Questions