LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-01-2011, 04:45 PM   #1
themattbeballin
LQ Newbie
 
Registered: Apr 2011
Location: St. Louis, MO
Distribution: Arch Linux
Posts: 1

Rep: Reputation: 0
Screen, Have to attach before finishing script


Hello there.

I've been working on a script for my Minecraft servers for a auto backup.

Well, when the server starts... It issues the following command...

Code:
screen -dmS BUKKIT1 /home/minecraft/BUKKIT1/minecraft.run
THEN... I have to attach the screen and detach it to make the rest of the script work... and I need a way around it, since this is automated, and I don't always tend to the machine...

This is the first command the backup script issues to the screen session:

Code:
screen -drS BUKKIT1 -X stuff "say SERVER BACKUP STARTING. Server going read only ..."`echo -ne '\015'`
What that does, is that it posts a message to the minecraft multiplayer saying "SERVER BACKUP STARTING. Server going read only ..."

But if I attach the screen session, then ^a d (CTRL+a d) it works fine.

I've done some searching, but I'm afraid I might not have been searching the correct terms, since I can't find a fix. There may not be one as well, but I figured someone has figured it out by now.

The server is running Arch Linux - Rolling Release, Kernel 2.6.37. Screen version Screen version 4.00.03 (FAU) 23-Oct-06.

Any help with this would be great.
 
Old 04-01-2011, 05:10 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
There is a long-standing problem with screen, in that it cannot accept commands ('-X stuff', for example) unless it has first been in attached mode. This is troublesome if it must be used in a system startup script, where the is no user to start the screen, and therefore no tty to which it can attach. I have contrived a very cumbersome solution to this problem, and it really isn't pretty.

First, launch an X virtual framebuffer (Xvfb). Then, use the Xvfb as the X server in which to launch an xterm. In the xterm, launch a screen session. Now, since the screen session is in 'attached' mode, you are free to stuff all the commands you like. You can attach to the session at any time later with a terminal connected to a real X server. I run all of this out of /etc/rc.local It helps to put some two or three second sleeps after each step, because things that take some time have to happen, like the virtual X server has to sort out where it finds fonts, bash has to go through some startup, etc.

--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a script to attach to a WiFi Network jdkorreck Linux - Newbie 1 04-22-2009 07:42 AM
Finishing Up Ace Blackwell Linux - Newbie 2 04-21-2008 11:39 AM
LXer: Tips and tricks: How do I use the "xm block-attach" command to attach additiona LXer Syndicated Linux News 0 08-21-2007 12:50 AM
Need help finishing Bash Script to add new user and map virtual e-mail info. O_Chaos Linux - Newbie 1 02-09-2004 04:06 PM
How do I zip and attach the output data of a grep | awk | mail shell script? 360 Programming 1 05-08-2002 08:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration