0

OS Centos 6.9, I've made a new screen session for a CSGO Server by using this command :

runuser -l '.$username .' -c "cd /home/'.$username .'/'. $username .'-'. $port .'/ && screen -A -m -d -S Server'. $port .' ./srcds_run srcds -game csgo -console -usercon '. $gamemodeline . ' +mapgroup mg_bomb +map '. $defmap . ' -maxplayers_override '. $max . ' +ip '. $host_ip . ' +port '. $port . ' -tickrate '. $tickrate . ' '. $cvars .'"

and i wanted to know if its possible to dump the screen content.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
anar chiff
  • 13
  • 8

1 Answers1

0

Well, you could try using tee

runuser -l '.$username .' -c "cd /home/'.$username .'/'. \
$username .'-'. $port .'/ &&                             \
screen -A -m -d -S Server'. $port .' ./srcds_run srcds   \
-game csgo -console -usercon '. $gamemodeline . '        \
+mapgroup mg_bomb +map '. $defmap . '                    \
-maxplayers_override '. $max . ' +ip '. $host_ip . '     \
+port '. $port . ' -tickrate '. $tickrate . ' '.         \
$cvars .'" |                                             \
tee -a /path/to/a/logfile.out

tee will allow the output to continue in your screen session while simultaneously outputting the data to the file specified after -a. The argument -a means append so the logfile will not get clobbered on subsequent invocations of your command. However, it's likely better than you either not use -a and use log-rotate or some other means of log management so that the log file doesn't get unwieldy.

There are probably even more elegant things you could do, but without knowing your specific use-case, this should work fine. I'm not exactly sure what the deal is with your liberal use of periods ('.') is, but if that works for you, cool. It looks like you're using them for concatenation, but that is totally unnecessary in shell. Maybe there's some other need for them. If so, do tell. :)

Jim
  • 1,499
  • 1
  • 24
  • 43