Forum OpenACS Q&A: Solution to Invalid command Name

Collapse
Posted by MaineBob OConnor on

The log file shows:

[21/Nov/2001:...[-conn0-] 
Error: invalid command name ""
invalid command name ""
    while executing
"[page_log "$user_id" "$this_user_id" "/is/$scr_name"]

This error does not occur when I add the proc to an adp file as in:

<%= [page_log "$user_id" "0" "/library"] %>

But does occur when it is part of another proc I have in /tcl. In tcl it is rendered as:

[page_log "$user_id" "0" "/library"]

The actual PROC is simple and it does work in updating the database. I just don't like cluttering up the log file...

proc page_log {owner_id viewer_id name} {
  set db [ns_db gethandle]
  ns_log Notice "Page Log: $owner_id  $viewer_id $name"
  set insert_statement  "insert into page_log (owner_id, viewer_id, 
name) values ($owner_id, $viewer_id, '$name')"
  ns_db dml $db $insert_statement
  ns_db releasehandle $db 
}

I have tried the above both with and without return. It has been placed after the:

ns_return 200 text/html $page_content

Thank you and Happy Thanksgiving!

-Bob

Collapse
Posted by mark dalrymple on
can you show us a couple of lines of context where the failing page_log call is failing? (say about 2 lines before and after the call, and the call itself)
Collapse
Posted by MaineBob OConnor on

Here is one location in the proc

append page_content "<p><font size=1 color=red>$user_id</font>
</font>
[x9_footer]
"
ns_db releasehandle $db
ns_return 200 text/html $page_content
[page_log "$user_id" "$this_user_id" "/is/$scr_name/learn$learn_id"]
return

-Bob

Collapse
Posted by mark dalrymple on
that's what I figured. You don't need the square brackets if the command is on its own. what's happening is this:
  1. Tcl reads the line
  2. Tcl scans through the line looking for square brackets
  3. It evaluates the stuff in the square brackets
  4. The result of the evaluation is substituted back in the line
  5. the line of code is then executed.
so in your code, Tcl reads [page_log ...]. Executes page_log, which returns nothing. Then tcl tries to execute that return of nothing.

If you drop the square brackets, it'll work.

Collapse
Posted by MaineBob OConnor on
Thanks mark,  That solved the problem.  I see that some of my
tcl files in the /www may have violated the rules and [included]
the square brackets where they are not needed.

-Bob