Hello,
This question is somewhat related to another I asked a while back:
"Convert flat log files to mySQL database"
http://www.experts-exchange.com/Web/Web_Languages/PHP/PHP_Databases/Q_21097456.html The solution worked very well, and I have been using it sinces then. However, now I would like to automate the process a more. Instead of having the individual log files 'pushed' to the server from which the script is run, I'd like the server to be able to go pull the details.
- The server is Win2K/Apache/MySQL/PHP and the client is Win2K.
- The client share and security are both set to 'Everyone' for the dir and files.
- Both machines are on an intranet and I have full administrative access.
So far, I have had some success with:
$dp = opendir('./');
while ($item = readdir ($dp)) {
if (eregi(".log$", $item)) {
$log = file($item);
for ( $i = 0; $i < count($log); $i++ ) {
...etc.
Everything runs as expected as long as $dp is set to the same dir that the script is in. After that, it's a bit odd.
Regardless of what I put for $dp (locally: '../', 'path/to/file' or to the client: '//servername/sharename', '\\\\severname\\sharename'
etc.) PHP throws a warning but I can get a list of the files:
example:
Warning: file(.): failed to open stream: Permission denied in c:\path\to\file.php on line 20
----->Log filename: .
Warning: file(..): failed to open stream: Permission denied in c:\path\to\file.php on line 20
----->Log filename: ..
Warning: file(2004.11.26.log): failed to open stream: No such file or directory in c:\path\to\file.php on line 20
----->Log filename: 2004.11.26.log
Warning: file(2004.11.25.log): failed to open stream: No such file or directory in c:\path\to\file.php on line 20
----->Log filename: 2004.11.25.log
Warning: file(2004.11.24.log): failed to open stream: No such file or directory in c:\path\to\file.php on line 20
----->Log filename: 2004.11.25.log
The '---->' indicates the part of the script that prints out what is happening with the file (logged, skipped, etc.) The result for '.' and '..' I can understand, but the rest are stumping me. It looks like the script has no trouble reading the contents of the share, so where is the problem?
As I write this, I begin to wonder if this has anything to do with accessing the share at all. Maybe the fact that the script won't deal with files outside of it's directory is the root of the issue.
Any ideas?
Start Free Trial