PDA

View Full Version : echoing text to a specific terminal/screen



rhpot1991
07-23-2004, 03:04 PM
OK, so here is my scenereo. I have 2 knoppix hd installed (now debian) boxes. One of them (Ultramagnus) runs pretty much the way that the installer had left it, on the other one (Cyclonus) I killed x-windows so it only boots to the command line, and it has no mouse/keyboard/monitor on it, I ssh into it whenever I need to do anything with it. Cyclonus' single point of existing is to run a Medal of Honor dedicated server. Everything runs fine and good, but what I want to do is automatically update a html file on an ftp site with the status of the server. In order to display the status of the server I must type 'status' in the terminal running the server. I have looked into a few different ways of doing this, the first and most desirable would be to capture the text displayed in the terminal, but because I run this under a screen I was unable to cat into a file. The second way, that I actually got working, is to run the server over ssh in a terminal on Ultramagnus then to take a screen shot of the entire screen. I have created bash scripts to take the screen shot and ftp it, but I cannot find a way to automate the 'status' command to the terminal. Anyone have any recomendations?

user unknown
07-26-2004, 05:22 AM
I'm not sure whether I got your problem understand right.
The 'status'-command is run on C and you need the output on U?
Here are my thoughts:

Run the 'status'-command by a sheduler like cron.
man crontab
look at /etc/cron.daily to get inspiration.
This will be a solution if you don't need to run it at very specific times - after something special happens.

Another idea: If you have a webserver running, create a cgi-script, which generates html, to show the status in your browser.

Instead of ftp you could use 'mailx' and send the result by email.
The ftp- or mailx- job might be started by cron as well.

rhpot1991
07-26-2004, 03:22 PM
Lets see if I can explain it a little clearer. The 'status' command needs to be run inside of the medal of honor server program, which itself is run inside of a 'screen' on Cyclonus, which I gain access to via ssh on Ultramagnus or Putty on my main PC. This cron looks like it may be helpful, I will have to check it out when I get home from work, I have a feeling I will run into the same problem with it that I ran into trying to bash script the 'status' command, I need to get it to actually send the command to the 'screen' running the MOH server, not just any terminal. I am pretty much looking to run the 'status' command every x seconds then ftp the screen shot, so that looks like it can be done easily with cron. I like to ftp it out so that I don't have to worry about taking bandwidth away from the server or anything else, and I also have a program running on my PC that updates the webpage with my current IP so that everyone can find the server, running it on a webserver locally would just add one more step.

user unknown
07-26-2004, 07:29 PM
I don't know 'medal of honor' - what is it? A game?

cron is working on a minute-base - so you can process commands every 60, 120, ... seconds, but not every 10, 90, ... seconds.

Your usage of 'screen' isn't clear to me too - a program isn't run inside a screen in my terminology, but runs on a machine and sends its output to a screen - normally on the same machine - but sometimes to a remote machines screen.

Do you start 'ssh cyclonos' on ultra, then start 'MOH', and call some 'status'-function inside the program?
Or is there a way to join the already running MOH-program?

rhpot1991
07-27-2004, 12:14 AM
Yes, Medal of honor is a game. When I refer to 'screen' I am refering to the program screen. Type 'screen' at a terminal and it will run, it allows you to run a program inside of the 'screen' and then detach it and resume the 'screen' at a later point, its great for ssh because you can pick up wher eyou left off when you get disconnected or connect from another location. The 'status' that I am refering to is a command that runs within the medal of honor server. The problem that I am having is that the medal of honor server runs till it is killed and if I make some sort of bash script to send the 'status' command to the MOH server program, the script will not actually send the command untill the prior (Medal of Honor) command is done running. Anyone can join the MOH server at any time, I use screen to allow me to get into the server program whenever or wherever I am, just incase I need to change any settings.

Basically this sums my whole problem up, how do I make cron send the command to the terminal/screen that medal of honor is already running in? It is not currently at a prompt and therefor cannot take commands like any normal terminal.

user unknown
07-27-2004, 02:37 AM
Ah yes - I understand.
Sorry - I didn't knew 'screen' and thought you're talking lazy/ vague.

Being not used to the usage of screen, it seems, you control it by stdin.
Now stdin might be redirected (and is often in unix-world).
You may redirect the output of a command to a file:

ls -l > filelist
and redirect the output to another program

ls -l | wc
so wc (wordcount) takes the output of 'ls -l' as input and counts that, while it normally would count userinput of stdin.
You can use a file as stdin by cating it to wc:

cat filelist | wc
or - more like output-redirection:

wc < filelist
So if you can write your commands to a file, do it, and rediredt it to screen.

(But I don't know, whether you can tell screen to pass arguments to the controlled program).

Having a permanent ssh-connection to MOH isn't an option?
And MOH has no option to configure it while running or in advance to give a status every x-minutes? How do other admins handle this task?

rhpot1991
07-27-2004, 03:03 PM
Unfortunately the Linux version of the dedicated server is not all the popular compared to the Windows version. I have seen several standalone programs that allow for stuff like this in the M$ environment but nothing for linux. As far as I know there is no way to script commands within the MOH server. The ssh connection is pretty much perminant from one linux box to the other, I just like to run the server in screen incase I close the terminal by accident or something, that way I can get back in to access it w/o having to kill the server and boot everyone who is playing. I will try some of your recomendations this week and let you know if I have had any success. Thanks for all the help.