[mrtg] renaming htm file - solved

David Eshelman deshelman at crawford.com
Fri Apr 27 10:54:02 MEST 2001



Hello all....

well i was totally confused by all this perl stuff...
so got one of my friends from www.openiris.com
to make a ASP script for me to solve my little problem

here is what it does
1. if you add the Directory option in MRTG it will post all files to the
directory you specify
2. Example: Directory[router1]: router1   (then all files will be in
\router1)
3. but now you have to change the default filename IIS points to for that
folder (point to router1.htm)
[Purpose to give individual clients access to mrtg reports]
4. this script when placed in the directory searches for the htm or html
file in the folder then
redirects to it.... (or whatever file extension you want, just edit code)
5. if no file is found it will display error message (edit code)
so... he said i may post the code for you all to use... and change...
if you make major changes/upgrades please email a copy to me explaining
what it does... thanks...  :)

copy and paste code...
name default.asp or index.asp whatever you please
as long as it is ASP!  :p
(IIS required or rewrite in jscript)

##########################################
## Begin Code ############################
##########################################

<%@ Language=VBScript %>
<% response.buffer=true %>



<%
'Create dictionary instances
  Dim objDict
  Set objDict = Server.CreateObject("Scripting.Dictionary")
  Dim objFSO
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  Dim strRootFolder
  strRootFolder = Request.ServerVariables("PATH_TRANSLATED")
  strRootFolder = Lcase(Left(strRootFolder, instrRev(strRootFolder,"\")))
Dim objFolder
  Set objFolder = objFSO.GetFolder(strRootFolder)
Set fc = objFolder.Files
     Dim File, strPath, strExtension

     'Iterate through each file in the folder
     For Each File in fc
       'Obtain the extension of the current file
          strPath = File.Path
       strExtension = Ucase(Right(strPath, Len(strPath) - _
                                InStrRev(strPath, ".")))
       If strExtension = "HTM" then
               response.redirect(File.Name)
       elseif strExtension = "HTML" then
             response.redirect(File.Name)

end if

next
response.write("No Files Exist!!!")
%>

###########################################
############### version 1.0 ################
## End Code ###############################
###########################################


hope you all found this helpful...

shout outs to www.openiris.com


regards,
------------------------------------
W. David Eshelman
Associate Network Engineer
Crawford Communications, Inc.
W: 678-421-6850
C: 678-665-5545
deshelman at crawford.com
www.crawford.com
------------------------------------

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list