LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 09-17-2003, 10:58 AM   #1
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
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?

Last edited by dolvmin; 09-17-2003 at 11:00 AM.
 
Old 09-17-2003, 11:17 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
You're better off running "monit". Check freshmeat.net for it.
 
Old 09-17-2003, 12:11 PM   #3
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
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?
 
Old 09-17-2003, 12:41 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
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.
 
Old 09-17-2003, 05:52 PM   #5
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
Open the script files for monit. It refers to copyrights.

I'll check out what you gave me... Thanks for the info.
 
Old 09-17-2003, 09:54 PM   #6
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
This statement works halfway.
It does report if nwserver is running.
It however, does not restart the server or report nwserver down.

I tried replacing the ./start.nwn with TEST=1

Then did a echo "$TEST"
read PAUSE
PAUSE=""

TEST showed up as absolutely nothing.
It did not print $proc(nwserver) is running.
nwserver "did" go down.

Can you explain to me how you are getting the result of a command into the memory?
 
Old 09-17-2003, 10:01 PM   #7
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
Oh boy. Well, I got it to auto start. <smiles> Give me a moment though, I need to verify it works both ways now.
 
Old 09-17-2003, 10:09 PM   #8
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
LINE: while [ "X$(pgrep $proc -d " ")" != "X" ]
SHOULD BE: while [ "X$(pgrep $proc -d "")"!="X" ]

THe spaces were causing the problem. Common mistake but very entertaining! <smiles>

Thanks abunch. It works 100% now.
 
Old 09-18-2003, 10:28 PM   #9
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
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: Reputation: 30
Dude!

I had a class today with a suprise quiz.

One of the things we needed to do is setup our "bashrc" file to load up:

Good afternoon, Chris. < if it's PM

Good morning, Chris. < if it's AM


If it was not for you, I would have never guessed it!

I put alittle thought into it and came up with this string! IT WORKED!

if [ "$(date +%p)" != "PM" ];then
echo "Good morning, $USER."

else
echo "Good afternoon, $USER."

fi

Thanks so much! <smiles>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Linux Scripting Issue Kicking my Butt !!! steve_f60 Linux - General 1 04-29-2005 04:00 PM
Slack 10.1 -- Mouse issue / X11 issue Pozican Linux - General 4 04-19-2005 03:44 AM
webmin issue, poss security issue bejiita Slackware 3 11-03-2004 06:07 AM
DNS issue or caching issue? AZDAVE Linux - Networking 7 10-02-2004 12:28 AM
Having Issue w/ Truetype fonts - Mozilla Issue clove Linux - Software 4 02-18-2004 08:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:18 AM.

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