serverizor
| |
This means that you can start up such programs once, and then connect to them with a command-line client (the same script, actually), and run commands, disconnect, connect again from some other machine, etc.. etc..
As a more concrete example, you can use it to boot up a large program such as emacs or lisp (in interpretor mode, not in editor/windowing mode) in the background, and then whenever you want to run emacs/lispy scripts you could just run a serverizor client with a few commands. Bingo!
The client and the server are the same program. Consider it to be like an intelligent client - it will start a server in the background if it needs one.
Come up with a regexp that will match (only) your shell prompt, such as '^\d+% ' and then call:
% serverizor -daemon="telnet some_host" \ -prompt='^\d+%' -watch='^login: '==some_user \ -watch=^Password:==some_pass \We choose the program and the prompt that we want to watch for that lets us know that we can take another command. We also setup some -watch prompts that will let us automatically login.
What's particularly cool about this is that you can run the client as a command-line option. As an example, start up just the server (with -start_server or else by disconnecting the first client that comes up). Then you can run a single command with:
% echo "ls" | serverizor
As another example, we can use serverizor to put an ftp session in the background:
% serverizor -daemon="ftp some_host" \ -prompt="ftp> " \ -watch='^Name \(.*\): '==some_user \ -watch=^Password:==some_passSame basic idea, just different prompts.
If you have trouble getting things working, you can start with a very simple shell based server. Start up a 'sh' shell and look at the prompt. It might be something simple like '$ '. If so, we can do:
% serverizor -daemon='sh' -prompt='\$ '(Note that we have to quote the '$' because it's a regexp). Now you can type some commands, and then disconnect while leaving the server running by typing '.' on a line by itself. Then run something like:
% echo "ls" | serverizorAnd you should see the output of just the 'ls' commmand.
Play around with it - but make sure you kill off any serverizors that you launch in the background with -stop_server. If you want multiple serverizors running at the same time then just specify a different port.
process ids of servers are saved in /tmp/pid.serverizor* as a default.
% apt-get install libexpect-perlThen download the perl script above and run it.