<br><br><div class="gmail_quote">On Sat, Nov 21, 2009 at 17:23, Donald Russell <span dir="ltr"><<a href="mailto:russell.don@gmail.com">russell.don@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

I have a PHP web page that builds a list of files from a particular directory.<br><br>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 <br>
<br>

exec('/sbin/fuser -v $fpath/$fname',$answer,$retcode);<br><br>Retcode is always 1 (not in use, or a "fatal error" happened) and $answer is always empty<br><br>From root, in the directory I'm  interested in I use fuser -v * and it shows me a couple of in-use items<br>


(for testing I have a little loop that gzip/gunzip a rather large file)<br><br>I tried /sbin/fuser from my own id and get the same results as apache... that is, nothing useful.<br><br>So I thought AH HA!, use sudo in the PHP script...<br>


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.<br><br>Back to the drawing board...<br><br>How can I issue a command from a PHP script that will "run as root" to get the fuser results for me?<br>


<br>In some cases the file are chmod 600 root root in other cases 644 <regular user> <regular user><br><br>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.<br>


<br>Any suggestions?<br><br>Thank very much.<br>
</blockquote></div><br><br>Solution:<br><br>$ chmod 6755 /sbin/fuser<br><br>I'm not sure that's a really good idea.... but it gets the job done pretty nicely.<br><br>I don't think that introduces any problems... only the program/command name is shown when using the -v option...<br>

<br>