Jessee Parker wrote:

> Hi all, I've run into a bit of a problem. I need to see if a program is
> currently running. If it is, I want to display this on a web page that
> tells the status of the program (either on or off). The script I created
> which is probably longer than it needs to be, basically issues a system(ps
> -A) call and writes it out to a file which in turns gets parsed through.
> This works fine from the command line. However, when I try to execute this
> same script by accessing the web page, it won't write the file to the
> directory which causes it to in turn display incorrect results. I am not
> sure what permissions a cgi-script (or the directory it resides in) should
> have so I didn't want to just try to change permissions to allow it to
> write. I may be approaching this the wrong way entirely so any help would
> be greatly appreciated!
> 
> Jessee

check out the Proc::ProcessTable module in CPAN for a replacement of your 
system(ps -A) thingy. it might prove to be easier to use and maintain and 
you don't need to create a tmp file for storing the output of ps -A.

if you really need to use a tmp file, you can try using the File::Temp 
module which can create tmp file for you and clean it up for you after your 
process is finish with it:

#!/usr/bin/perl -w
use strict;

use File::Temp qw/tempfile tempdir/;

my ($tmp_handle,$tmp_file) = tempfile(DIR => tempdir(CLEANUP => 1));

#-- do whatever you need to to with $tmp_handle($tmp_file)

__END__

when your process is finished, the tmp file is cleaned up for you 
automatically. this way, you don't have to worry about the permission 
thingy.

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to