A Terminal Anywhere
By default Anyterm presents a shell running with the same uid as your web server, but you can run any program you like. You could directly run a text-mode application if you wanted (see the demo page for an example).
To specify the command to run, put an anyterm_command line in your Apache configuration, e.g. in your .htaccess file:
Anyterm expands %h in the command to the hostname (or IP address) of the client (you need "HostnameLookups On" in your Apache configuration to get names rather than IP addresses; you can put this in a <Directory> section but not in a .htaccess file). Other expansions could be added in the future. If you need a literal % in the command, write %%.
The command is run using "/bin/sh -c", so it can include input/output redirection and other shell features. You can also preceed the command with environment variable settings. This can be useful for adjusting the terminal type ("linux" by default) or locale. For example, "LANG=en_GB foo" runs foo with a British English locale.
If you want to present a login: prompt you need something that does what /sbin/getty and /bin/login do for real logins. anygetty is a small C program based on mingetty that tries to do this; it should present the same interface and environment as a real console login. To compile it, just "make" in the anygetty directory.
There are some permissions complications with anygetty and /bin/login. anygetty needs to write to utmp, and /bin/login needs to run as root. On some systems /bin/login is setuid root, but on others it is not.
If you haven't go this right you might get the message No utmp entry. You must exec "login" from the lowest level "sh" after entering your username.
Some systems, including Gentoo, have a version of /bin/login that calls vhangup(). Check your login man page. This cannot work with anygetty; the symptom may be that anygetty hangs after you have entered your username, or you get an error about not being able to set permissions on the TTY. I would welcome advice about a possible work-around; it is likely that simply removing the call to vhangup would be sufficient to make it work.
If you're using a system with SE-Linux security features, such as Fedora Core 3, you may find that they further complicate things. This probably just needs a slight change to a configuration file somewhere to make it work; if someone knows what is required please get in touch.
ROTE uses a one-byte-per-character array to represent the screen, so Anyterm is limited to using a one-byte fixed-size character set. The obvious choice for most applications is iso-8859-1 and this is the default, but you can specify a different one by changing the definition of CHARSET in anyterm.h. Anyterm uses iconv to convert incoming keys to this character set as they arrive. For outgoing screen data Anyterm doesn't do any conversion, but simply labels its output with the specified character set; it is then up to the browser to do any needed conversion before displaying it on the screen.
Of course you need to set up your environment so that the programs you run inside Anyterm know what character set to use. See the notes above about setting environment variables.
I have tried experimenting with the box-drawing characters as used by some curses applications. When I eventually managed to get them to display I was disappointed to find that they mess up the screen layout: Firefox can't find those characters in its fixed-width font, and substitutes wider versions. If anyone gets this to work on Linux please let me know how you did it.
You can adjust the size of the terminal, but only globally, and you need to recompile the apache module. Just change the definitions of ROWS and COLS in anyterm.h. You should also consider increasing the value of max_screen_size; this is the maximum size of the HTML representation of the screen, which could be very large in a worst case where every character was a different colour from its neighbours.