Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help on finding if a server program has finished running

Status
Not open for further replies.

zaphbrox

Technical User
Sep 29, 2000
5
0
0
US
Hi all,

I have an application which loads a large amount of data, does a lot of processing on this data, and once this processing is complete, starts listening to a pre-specified port for any requests/commands from client programs. The program at this point establishes itself as a server to the client programs.


Is there any way I can write a perl script to find out if the server program has finished loading data and has started listening to the port for messages? I need scripts for both Unix and NT environments.

The server does not write any output to any flat files. In addition, if I were to redirect the messages of this application to a file and constantly monitor this flatfile till I find a message equivalent to its listening to the port, the file searching would takes ages, since it is rather verbose in its log message.

I am looking for the equivalent of a "ping" to this program.

Thank you very much in advance.

regards,
ZB [sig][/sig]
 
Hi Zaphbrox.

Looks like you are not getting much help on this post. Unfortunately, I am not able to help you either. But after reading your post, I thought perhaps you could help me.

I am writing a Perl script that is supposed to kick off when our server receives a file of any name into a specific directory. I really don't want to have the Perl program running all the time (I could write it to loop and look for files, but that would take all the CPU and bring our poor server to its knees). It has been suggested that I make it an NT service (this is on an NT server, by the way), but this program is supposed to process in a real-time environment. I don't want to set it up as a service to run every 5 or 10 minutes...it needs to run the instant a file is FTP'd into this specific directory. And from what I understand from the Tech Services guys who take care of the server, if I set it up as a service on NT, it has to be set up to run at specific times or in specific intervals of time.

It looks like you may have some idea of how to do this, since you've apparently written a program that listens to a port for incoming data.

Did you write this program in Perl? If so, how did you make it 'watch' a specific port? Or is this some sort of server 'service' type thing?

Any information on this that you could pass on to me would be most helpful.

Thank you! s-)

Kathy
 
ZB,

Have you considered setting $0 to reflect what the program is doing at that moment?

You could set it like this:

$0='Server_Prog-Processing'; # when loading data$0='Server_Prog-Listening'; # when listening

The name of the prog then changes when viewd in a process list (ps)

This isn't much of an NT solution though, unless you can get a process listing in NT (I can't, in perl anyway)

Kathy,

If you tried something like this in a perl script set to run as a service it would not take up much CPU time at all:

# loop forever
while(){
# if the file file.txt exists
if (-e 'file.txt'){
# process it
do_something('file.txt');
}
# go to sleep for 1 second
sleep 1;
}
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top