From: Zoran V. <zv...@ar...> - 2005-03-08 09:43:25
|
On Tuesday 08 March 2005 09:09, Stephen Deasey wrote: > I'm not sure what the right way to go here is. Would such an nsdsh be > useful, or should we just add more to the server binary, or should I > just be a bit more creative when writing tests..? > I do not know if this is what you'd need... What we've done is to spawn a thread on server start which opens a named pipe on the filesystem. The location and naming convention of the named pipe is well known. The thread reads incoming data more/less the same as nscp and executes the command. We also wrote a very tiny utility in Tcl (and wrapped it into a single exectuable with mktclapp) which also connects to the same named pipe, reads stdin for commands and passes the input to the pipe. This looks like: zvlinux:/usr/local/homes/zv # cd /usr/local/aw zvlinux:/usr/local/aw # bin/nsdchat % srvinfo version 4.0 The "nsdchat" is this small utility. This way we can execute any server command on a running server instance. The thread which reads the pipe executes command in a secure Tcl interp and we have opened a special API for that. This need not be, of course. So, this way we are actually using the server itself to run arbitrary scripts. The nsdchat utility can also read files on the filesystem and pass them to server for execution: zvlinux:/usr/local/aw # echo "srvinfo version" > my.tcl zvlinux:/usr/local/aw # bin/nsdchat < my.tcl 4.0 Is this the functionality you're looking for? Cheers Zoran |