Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Warning stat failed for...

Posted by chris (chris), 8 March 2003
Hi there,

i have a problem with a script that should evaluate the last access to some files with the function  fileatime()

while ($file = readdir ($handle))
           if ($file != "." && $file != "..")
             echo fileatime($file)."\t";

Normally this piece of code should echo the unix timestamp for all the files in the directory 'online', but instead I get a warning:

Warning stat failed for filename (errno=2 - No such file or                               directory) in line .....  

even though the files exist. In fact the have only just been created by another script.
Any Ideas why this is happening?



Posted by admin (Graham Ellis), 8 March 2003
Hi, Chris ....

Four quick thoughts.  

Firstly - are symbolic links involved?  Is it possible that your script is looking at a link that points to a non-existant file?

Secondly - is the script that just created the files running as another user?  If the directory "online" is your own directory and doesn't have enough permissions for the web server user, you maye get this sort of problem (you'll need both r and x on the directory in order to both see file names and their inode details)

Third - are you crossmounting file systems / working between two different systems (but I'm just having second thoughts about this idea ... not quite consistent with the evidence).

Fourth idea (and in review, my hot favourite - I think you need to add the directory name in front of $file in fileatime - as the code stands you're looking at a file in the CURRENT directory based on a name in the atime directory.  LIne should read:
         echo fileatime("online/$file")."\t";

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho