Trouble opening files

Westbrook, Christopher L (WESTBCL04) WESTBCL04 at juniata.edu
Sun Jan 29 01:19:31 CET 2006


I am having some trouble, and I can't figure out why.  I'm trying to use
the simple keylogger project from source forge, and then create a web
interface to open the resulting files, so people from the outside can
see the keys logged on a server.  I've got the keylogger script working
fine, and I have a script that reads and displays all the directories
and files of the log directory, but when I select the link of the file
it doesn't open.  I've made some changes to the pykeylogger source,
mainly using @@ between the date and window name rather than _ and
getting rid of the window handle.  First, I have placed the script that
makes the page with the lists of the directories and files, and then
I've pasted the script that opens the file, or at least attempts to.
Can someone help?
#!c:\python24\python.exe
import os
print"Content-type:text/html\n\n";
print"<html<head><title>directory list</title></head><body>"
for f in os.listdir("c:\\temp\\logdir"):
	print "<h1>",f,"</h1>\n"
	subdir = os.path.join("c:\\temp\\logdir",f)
	#debug info here
	print "<br/>subdir=",subdir
	

	for g in os.listdir(subdir):
		print "<br/>g= ",g
		file = os.path.splitext(g)[0]
		print "<br/>file=",file
		fullPath = os.path.join(subdir,file)
		[date, name] = file.split('@@')
		
		print "<a
href=\"read.py?file=",fullPath,"\">",name,"</a>"
		print "<br/>last modified: ",date
	
	#now for the script that opens the file
#!c:\\python24\\python.exe

#import re
import cgi
import string

form = cgi.FieldStorage()
print "Content-type:text/html\n\n";
filename = form["file"].value+".txt" #all files end in .txt extension

filename = filename.replace("\\","\\\\")

#print filename

f = file(filename,'\r') #open file for reading
for line in f:
	#replace carriage returns with html newline characters
	line = line.replace("\r","<br/>")
	print line
	
I'm running this on a windows machine.  Any help would be appreciated.




More information about the Python-list mailing list