Hi All,
I'm a newbie.
I need to know if we can write a script that tracks the number of times an xls file was downloaded in a day.
I tried searching many books & websites, but of no use.
Kindly show me the way..
Please..
Thanks
Hi All,
I'm a newbie.
I need to know if we can write a script that tracks the number of times an xls file was downloaded in a day.
I tried searching many books & websites, but of no use.
Kindly show me the way..
Please..
Thanks
This ugly bit of PHP code works for what we want to do, which sounds similar to what you want. It should be a good starting point.
searchfile is the concatenation of the website's access logs
$key is the filename you want to check for being accessed.
$COUNT=shell_exec("cat searchfile | grep $key | wc");
shell_exec("cat searchfile | grep $key > searchfile2");
shell_exec("rm searchfile");
shell_exec("touch searchfile");
Hi Donald, Thanks a lot for your help.
But where can I find this file "website's access logs"?
Thanks
The webserver should keep track of it. I believe it should be in one of the Apache directories for Apache servers. I'm not too familiar with other servers to know how they work, but I suspect that they are similar in operation.
Do a search on the files on your server for something like, this is the format that they should be in for each time anything on your server is accessed.
xxx.xxx.xxx.xxx - - [06/Jul/2009:16:16:29 -0400] "GET /DIRECTORY/FILE.html HTTP/1.1" 301 360 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
where xxx.xxx.xxx.xxx is the IP address from which the file is accessed and DIRECTORY/FILE.html is the file we're interested in people accessing.
LOOK HERE for more info on the webserver access logs.
Hi donald,
Thanks a lot for the reply.
Am not clear with the code mentioned by you.
How do I search this & where. Please advise..
Do you have FTP access to the actual web server? In the Apache HTTP server directory is where the logs are kept. See the link I posted for details on the log.
The "code" I posted is just the format of the log entry, not really code, per se. If you have access to the web server you would just search the appropriate directory for a file containing that type of syntax.
I'm not using Apache server.
Am unable to search for the access log file.
Please advise
I'm not using Apache server.
Am unable to search for the access log file.
Please advise
I'm not sure of how you could go about doing it then. That's just the solution I came up with to figure out if customers had downloaded update files from our website. It's somewhat convoluted though, perhaps someone else here knows of an easy way to do it.
Good luck!
Can anybody help me with this?
if we can write a script that tracks the number of times an xls file was downloaded in a day.
PLease advise ASAP.
What webserver are you running? What language is the site written in? What access do you have to the server?
You haven't provided enough information for anyone to form an approach....
None of those. This is simply accessing a file on a shared disk. Not a download at all. Take a look at his other threads on this forum about access times and downloads.
Hi All,
My requirements have been changed.
The new reqirmnt is in javascript.
Thanks for all ur responses.
How is javascript going to help with this when there is no server and no html, or anything else that has anything at all to do with JavaScript? Or is this really a download after all? Even though you said it wasn't? Is there a server now? Where did it come from if there wasn't one before? JavaScript would still have nothing to do with it though. Either parse the access log or only allow the "download" through a cgi/jsp/php/whatever rather than a direct link and have the page that delivers the file "increment the counter", as I already suggested in one of your other threads before you claimed that it wasn't a download at all.
if the system is gnu/linux or unix you could use the inotify tools to monitor the file system events
I've made a test and it works quite good for what you're asking for. With this command you could get complete info about accesses to the file in the last tX seconds, check the manpage for more options.
serpiko@PALM-VAIO:/tmp$ inotifywatch -t30 /home/user/filename.xls
Establishing watches...
Finished establishing watches, now collecting statistics.
total access close_nowrite open filename
8 2 3 3 /home/user/filename.xls
Seen in
http://ubuntuforums.org/archive/index.php/t-1121012.html
hope it helps
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.