blag: convert (and slightly improve) blogposts from rohieb.wordpress.org
[www-rohieb-name.git] / blag / post / gnu-screen-start-with-multiple-windows-and-commands.mdwn
diff --git a/blag/post/gnu-screen-start-with-multiple-windows-and-commands.mdwn b/blag/post/gnu-screen-start-with-multiple-windows-and-commands.mdwn
new file mode 100644 (file)
index 0000000..b0b8466
--- /dev/null
@@ -0,0 +1,34 @@
+[[!meta title="GNU screen: start with multiple windows and commands"]]
+[[!meta date="2010-07-30"]]
+[[!meta author="rohieb"]]
+[[!meta license="CC-BY-SA 3.0"]]
+
+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
+`screen` session.  This is nearly trivial, `screen -dmS yoursessionname
+yourcommand` is your friend, and you can later on reattach using `screen
+-r yoursessionname`.
+
+But what if I want to start multiple commands, each in its own screen
+window? My first solution used `screen -dmS` followed by something like
+`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"`, but it seems that the `next` command fails in this
+context, and I ended up with all the mess in one single window.
+
+My next approach (okay, it took me half an hour of reading [the
+manual][0] until here ;-)) was more succesful: I created a session
+command file which contained screen commands like this:
+
+    screen
+    select 1
+    title "my window title"
+    exec mycommand arguments ...
+
+[0]: http://www.gnu.org/software/screen/manual/
+
+And, voilĂ , I could paste the single command line into my crontab:
+`screen -dmS sessionname && screen -r sessionname -X source
+sessioncommandfile`
+
+[[!tag hacking howto cron GNU screen]]
This page took 0.019444 seconds and 4 git commands to generate.