Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289
Rep:
Scripting issue.
Hey folks, thanks for reading. I need some help. I run a game server using nwserver from NeverwinterNights. I noticed it is a bit, buggy? Sometimes it goes down. I want to create a script file that detects when it goes down and loads it back up. I'm having difficulty with 1 line. Here's what I got.
#! /bin/bash
# Chris Jepson
# 09-17-03
# ./autostart.dat
# This file detects the status of nwserver & if down, restarts it.
STATUS=ps -A > status.mem
FILTER=grep -o nwserver status.mem > filter.mem
PROCESS= # *My problem! input text from file "filter.mem" into memory.
LOOP=1
while ["$LOOP"!=0 ]
do
sleep 6
$STATUS # Check all processes
$FILTER # Filter for process nwserver
case $PROCESS in # check for nwserver in varable.
[nwserver]) clear;; # nwserver in varable, do nothing.
*) ./start.nwn;; # nwserver not in varable, restart it.
esac
done
I need to get the text in the file "filter.mem" into memory as if I was to use "read PROCESS" and type it in manually. That way my case statement would work. Could someone help please?
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289
Original Poster
Rep:
As powerful and interesting as this monit program may be, I would still like to know what I am doing wrong with my own script.
I'm running the game server, not just for enjoyment but, also for practice in administration w/ Linux. I want to learn as much as I can within the field. Monit may be freeware, but it is also lisenced software. If I was in a corperation, installing it could lead to my termination. Most corperations now higher admins who have some programing experience as well. They want the admins to create script files. They would not settle for Monit until after they had me complete a script file first.
Besides, this script program I am trying to make is only a peice of the entire thing I'm making. I already have 3 scripts up, including a menu, a database to allow me to see which players are logged on by using grep & ark within the nwserver log file and more. Monit does not do this for me. In addition, my script files work in command line, some do not work in the xwindows and most administration w/ Linux is done the same way. Monit is a great tool, but not for me right now.
I also need to practice providing access rights to remote login users on ssh. I can already see that Monit is confusing the living hell out of me, in that dept. Though Monit does support ssh, it's complexity is throwing me off. I may mistakenly give to much rights to someone undeserving of it, if I use Monit. I don't want that make that mistake.
Is there a way I can foward text information from a file, into memory?
As powerful and interesting as this monit program may be, I would still like to know what I am doing wrong with my own script.
Let's say you're using the wrong method. I could transmogrify your script, but this is easier, because you'll use tools for process listing:
#!/bin/bash
proc=nwserver; while [ "X$(pgrep $proc -d " ")" != "X" ]; do pgrep $proc -d " " >/dev/null && echo $proc is running... || ./start.nwn; sleep 30s; done
Monit may be freeware, but it is also lisenced software. If I was in a corperation, installing it could lead to my termination.
WTF? Monit is GPL'ed!
I also need to practice providing access rights to remote login users on ssh. I can already see that Monit is confusing the living hell out of me, in that dept. Though Monit does support ssh, it's complexity is throwing me off. I may mistakenly give to much rights to someone undeserving of it, if I use Monit. I don't want that make that mistake.
Caution is good, but you're confusing things.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.