SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Rome
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file_exists problem

    Hello

    I have to execute this

    Code:
    $cmd=@shell_exec("find /home/*/public_html/ -type f -mtime +10");
    sometime it returns

    find: /home/test/public_html/: No such file or directory

    Also with @ before shell_exec. To avoid the "find" linux error I tried this

    Code:
    if (file_exists("/home/*/public_html")) {
    $cmd=@shell_exec("find /home/*/public_html/ -type f -mtime +10");
    }
    but it does not work because file_exists does not work with "*".

    Any solution to avoid (not show) the "find" error ?


    Thanks!

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    probably just wrapping the line in an if() should do it.
    PHP Code:
    if(!$cmd=shell_exec("find /home/*/public_html/ -type f -mtime +10")) {
        return 
    false;
        
    // or some other output

    Edit:


    Cant test it fully as I am on windows.........
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post

    Edit:


    Cant test it fully as I am on windows.........
    btw, there are native (e.g. not cygwin) ports of some utils, including find.
    works great for me

    http://gnuwin.epfl.ch/apps/unxutils/en/index.html
    the development seem to be stopped though ;(

  4. #4
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Rome
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    probably just wrapping the line in an if() should do it.
    PHP Code:
    if(!$cmd=shell_exec("find /home/*/public_html/ -type f -mtime +10")) {
        return 
    false;
        
    // or some other output

    Edit:


    Cant test it fully as I am on windows.........

    Thanks but no good on linux ..

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by stereofrog View Post
    btw, there are native (e.g. not cygwin) ports of some utils, including find.
    works great for me

    http://gnuwin.epfl.ch/apps/unxutils/en/index.html
    the development seem to be stopped though ;(
    Thanks for the link Stereofrog, I will have a look through it
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    SitePoint Evangelist -T-'s Avatar
    Join Date
    Jun 2002
    Posts
    444
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I remember correctly, you are a able to see directories in home that you are not allower to read/write to, but you can not see the directories under that. So find will return an error if you look for a file in a directory you do not have read/write access to

    Try running the cmd in in shell while you su to the apache user. That should give you an idea of how it reacts. If you do not have a root account and you're on a shared server there is big chance that your host have added preventatives so users can't index each others dirs ^^
    chrome is a wrapper that combines a browser with spyware


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •