how to get /sbin/fuser results from apache php script?

Donald Russell russell.don at gmail.com
Sun Nov 22 01:23:45 UTC 2009


I have a PHP web page that builds a list of files from a particular
directory.

In that PHP script I want to include some information about "what is using
the file" (i.e ftp, gzip, cp etc.. so I code

exec('/sbin/fuser -v $fpath/$fname',$answer,$retcode);

Retcode is always 1 (not in use, or a "fatal error" happened) and $answer is
always empty

>From root, in the directory I'm  interested in I use fuser -v * and it shows
me a couple of in-use items
(for testing I have a little loop that gzip/gunzip a rather large file)

I tried /sbin/fuser from my own id and get the same results as apache...
that is, nothing useful.

So I thought AH HA!, use sudo in the PHP script...
I got an error message from sudo saying a tty is required to use sudo even
though I had that command set up to not require password.

Back to the drawing board...

How can I issue a command from a PHP script that will "run as root" to get
the fuser results for me?

In some cases the file are chmod 600 root root in other cases 644 <regular
user> <regular user>

I want my web page thing to show me the files in-use... I can live without
the 600 root-root files, but I really need to see the others.

Any suggestions?

Thank very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20091121/c452cd38/attachment-0001.htm>


More information about the fedora-list mailing list