Home > ASP Development > Capture Server Variables

Capture Server Variables



I'm capturing server variables from the visitors to one of my sites using the following code:



FOR EACH name IN Request.ServerVariables

Response.Write ("<P><B>" & name & "</B>:")

Response.Write (Request.ServerVariables(name))

NEXT



What I would like to do is capture this information to a text file. Would anyone know how to accomplish this so that as soon as a visitor enters my site, the server variables are captured and automatically sent to a text file? Thanks.

    
Guest


use such code

Code:


<% 
'***************** CreateTextFile 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set folderObject = fso.GetFolder(Server.MapPath("\fso") & "\") 
Set textStreamObject = folderObject.CreateTextFile("testfile.txt",true,false) 

textStreamObject.WriteLine("a new text file") 
textStreamObject.Close ' remember to close it so that it writes the file 

Set textStreamObject = Nothing 
Set folderObject = Nothing 
Set fso = Nothing 

' Creates a text file called "testfile.txt" in the folder, overwrites if it exists 
' and sets it to ascii (false to indicate not unicode). Then write "a new text file" 
' to the testfile.txt, and closes it 
' NB remember the trailing slash in the GetFolder method 
%>




http://www.sloppycode.net/Reference/FSO/Ref-145.html

Was this answer helpful ? Yes No   
Guest


This worked great! Can you think of a way in which this file would update or keep growing instead of overwriting the file? In other words, I want to keep a list of IPs and I want it to just keep growing instead of writing a new file with just one IP in the file. Thanks.

Was this answer helpful ? Yes No   
Guest



Code:


Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile("C:\text.txt", 8, True)
WriteStuff.WriteLine(Stuff)






the 8 means append. a 2 is overwrite.



Hope that helps some.



Cheers,



Dean

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved