Hello,

This is my first post and I have a question.  I'm using some code I got off
the wiki for access a users public_html directory.  I keep getting the
following error when trying to start nsd (on linux: fedora Core 1)

[11/Apr/2004:21:23:56][4502.16384][-main-] Notice: config.tcl: starting to
read config file...
[11/Apr/2004:21:23:56][4502.16384][-main-] Fatal: config: script error:
invalid command name "ns_register_proc"
    while executing
"ns_register_proc GET /users/ homedir"

What is wrong here...all the examples say that this should work as well as the
aolserver docs.

Here is the snippit of code I'm using:

proc homedir { conn ctx } {
   set url [ns_conn url $conn]
   set user {}
   set file {}
   regexp {^/users/([^/]*)(/.*)?$} $url dummy user file
   # ns_returnnotice 200 "url is $url user is $user, file is $file"
   set userfile [getUserFile $user $file]
   set type [ns_guesstype $userfile]
   if {[string match "*[ns_config ns/server/[ns_info server]/adp map]"
$userfile
]} {
     # ns_log notice "adp parsing $userfile"
     set cwd [pwd]
     cd [file dirname $userfile]
     # ns_return 200 text/html [ns_adp_parse -file $userfile]
     set result [catch {ns_adp_parse -file $userfile} error]
     if {$result} {
       ns_return 200 text/html $error
     } else {
       ns_return 200 text/html $error
     }
     cd $cwd
   } else {
     switch $type {
       "*/*" {
       }
       default {
        ns_returnfile 200 $type $userfile
       }
     }
   }

   if {[catch {set fp [open $userfile]}]} {
     ns_returnnotfound
     return
   }
}

proc getUserFile {user path} {
   foreach tail [split ,[ns_config ns/server/[ns_info server]
directoryfile] ,]
{
     set userfile "[glob ~$user]/public_html$path$tail"
     if {[file exists $userfile] && ![file isdirectory $userfile]} {
       return $userfile
     }
   }
   ns_returnnotfound
   # break
}

ns_register_proc GET /users/ homedir
ns_register_proc POST /users/ homedir
ns_register_proc HEAD /users/ homedir

proc userRedir {conn arg why} {
   set url [ns_conn url]
   regsub {^/~(.*)} $url {/users/\1} redir
   ns_log notice "url is $url, redir is $redir"
   ns_returnredirect $redir
   return filter_break
}

ns_register_filter preauth GET /~* userRedir

Can anyone help me out?

Adam Watson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to