pages tagged screenrohieb.namehttps://rohieb.name/blag/tag/screen/rohieb.nameikiwiki2013-09-19T05:04:01ZGNU screen: start with multiple windows and commandshttps://rohieb.name/blag/post/gnu-screen-start-with-multiple-windows-and-commands/rohieb
CC-BY-SA 3.0
2013-09-19T05:04:01Z2010-07-29T22:00:00Z
<p>I wanted to restart my IRC bot on reboot, but I also wanted to have
control over it and see its log output, so I wanted to start it inside a
<code>screen</code> session. This is nearly trivial, <code>screen -dmS yoursessionname
yourcommand</code> is your friend, and you can later on reattach using <code>screen
-r yoursessionname</code>.</p>
<p>But what if I want to start multiple commands, each in its own screen
window? My first solution used <code>screen -dmS</code> followed by something like
<code>screen -r sessionname -X screen; screen -r sessionname -X next; screen
-r sessionname -X title "my window title"; screen -r sessionname -X exec
"my command line"</code>, but it seems that the <code>next</code> command fails in this
context, and I ended up with all the mess in one single window.</p>
<p>My next approach (okay, it took me half an hour of reading <a href="http://www.gnu.org/software/screen/manual/">the
manual</a> until here ;-)) was more succesful: I created a session
command file which contained screen commands like this:</p>
<pre><code>screen
select 1
title "my window title"
exec mycommand arguments ...
</code></pre>
<p>And, voilĂ , I could paste the single command line into my crontab:
<code>screen -dmS sessionname && screen -r sessionname -X source
sessioncommandfile</code></p>