title: How can I evaluate a Q script in a running KDB server?
body: <p>I have a large table that I want to partition loaded in a kdb+ server. The partitioning code is in a Q script that I need to evaluate on the server, but I don't have I/O control over it (the server is running in the background, data in memory was loaded through the C API).</p>
  
  <p>So far the only solution I've found is to open a handle and convert all my statements to strings (all those \" I have to use look quite messy):</p>
  
  <pre><code>if[4 &lt;&gt; count .z.x; 0N!"usage: part_md.q host port db_dir date (YYYY.MM.DD)"; exit[1]]
  
  arg_host: .z.x 0
  arg_port: .z.x 1
  arg_db_dir: .z.x 2
  arg_date: "D"$(.z.x 3)
  
  /get server handle
  h:hopen `$(":",arg_host,":",arg_port)
  set_db: "db: \":",arg_db_dir, "/mydb/\""
  set_sym_path: "sym_path: \":",arg_db_dir,"\""
  h set_db
  h set_sym_path
  
  /select fields to partition
  h "mydb_select: select [-10] A,B,C from mydb"
  
  /enumerate symbols
  h "md_select_enum: .Q.en[`$sym_path] md_select"
  h "delete md_select from `."
  ...
  </code></pre>
  
  <p>How can I evaluate my script directly without using a handle to the server on the same machine?</p>