Previous Next Contents

4. Logging in via kermit.

Configuring Linux to use the Mac as a login: terminal is even easier. kermit is ideal for this purpose, because it is one of the few free communication programs which provides credible VT100/120/220 emulation.

Essentially, what you want to do is start kermit on the Macintosh side as in the previous section, but rather than issue server commands, you enter connect mode. This is the normal terminal emulation mode that most people use, anyway.

On the Linux side, the serial line must be configured with a getty on it to start a login: shell. To do this, you need to tell init that the serial line has a terminal on it. In your /etc/inittab file you will need a line something like this:

T1:23:respawn:/sbin/getty -L ttyS0 9600 vt100
Be sure to substitute the appropriate serial device for /dev/ttyS0 and the correct baud rate for 9600 in the command line above.

This command tells getty to start login (the -L switch) on the terminal display, and, when the login times out, to re-start (respawn) the login program until someone logs in. If no device is connected to the serial line, or if the connection is defective, you may see a message on the system console like: /dev/ttyS0 respawning too fast: disabling for 5 minutes. If this happens, you can return things to normal by (as root) killing the getty process, or using the init q command. Both of them have the effect of re-spawning the getty processe(s). If everything is in order, you should see the Linux banner and login prompt on the Mac's kermit window. That's all there is to it.

Also, if you use something besides vanilla getty, like getty_ps, the command above will look somewhat different. The important thing to remember is that everything to the right of /sbin/getty is an argument for getty itself; not init. You should look at the manual pages for getty, init,and inittab if you have questions concerning the setup of init and getty.

The Serial HOWTO provides helpful details on how to configure /etc/inittab for getty_ps, if that's what your system uses.

To transfer files back and forth between the Macintosh and the Linux machine, you can (via the Mac's Kermit) issue the kermit -x command to start the Linux kermit in server mode. You can then use the normal file transfer commands to send files across the serial line. It's useful to set a prompt in your ~/.kermrc with a line like

set prompt Linux-kermit >
Otherwise, remembering which machine you're on can quickly become confusing.

4.1 Other Mac terminal programs.

This method should work equally well for any other Mac terminal program. If you have ZTerm, you can use rz and sz on the Linux machine to transfer files via the ZModem protocol. If Microphone Lite came bundled with your fax modem, that works equally well, albeit without kermit's superior scripting and configuration facilities.


Previous Next Contents The MacTerminal MINI-HOWTO: Conclusion. Previous Next Contents

5. Conclusion.

If you have questions about any of this material, or suggestions for future directions of Mac-Linux serial-line connectivity, don't hesitate to drop me a line at kiesling@terracom.net.


Previous Next Contents The MacTerminal MINI-HOWTO Previous Next Contents

The MacTerminal MINI-HOWTO

Robert Kiesling

v1.4, 9 November 1997


This mini HOWTO describes the 1,002nd use for a dead Macintosh (grin): how to configure the Mac for use as a Linux terminal. Configurations using getty and the terminal program kermit are described, as well as using kermit peer-to-peer networking between between Linux and a Macintosh. This document may be reproduced freely, in whole or in part, provided that any usage conforms to the general copyright notice of the HOWTO series of the Linux Documentation Project. See the file COPYRIGHT for details. Send all complaints, suggestions, errata, and any miscellany to kiesling@terracom.net, so I can keep this document as complete and up to date as possible.

1. Introduction.

2. Setting up a serial link.

3. Client-server connection with kermit.

4. Logging in via kermit.

5. Conclusion.


Previous Next Contents Conclusions

5. Conclusions

The previous discussion illustrates the steps I took to tighten up my memory usage on my Linux box. Hopefully I have provided you with some insight into what you can do with your Linux box to conserve memory. Good luck and happy hacking!

Daemons

4. Daemons

Many Linux distributions run daemons most of us will never use. Most of these daemons are loaded by scripts. Where these scripts are and what they are called depends on your Linux distribution. Slackware set-up scripts are buried in /etc/rc.d/rc.*.

Before you proceed, a knowledge of Unix shell script programming would be a definite asset. However, if you have no experience writing Unix shell scripts, what follows is probably the quickest introduction to shell script programming ever written.

Take the following shell script:

#!/bin/sh echo "hello world" 
			#echo "good bye cruel world"

The previous code will echo the string "hello world". Shell scripts must contain the the line
"#!/bin/sh"
at the very top line. After that every line is executed as if you had typed it at the keyboard (think of shell scripts as nothing more then glorified keyboard macros).

Lines which begin with a '#' are said to be commented out because they do not get executed by the shell. Most start-up scripts when they load daemons look like:

if somecondition 
		        do something 
				  fi

What you want to do is comment out every line starting with the
if
statement and ending with the
fi
statement.

If you want to find where a daemon is loaded, search the start-up scripts for the name of the daemon. If I wanted to find where inetd is loaded in Slackware I would do the following:
$ cd /edt/rc/d $grep -n inetd rd.*

4.1. inetd

inetd allows people to do things like telnet, ftp, and send talk requests to your machine. If you never use your system as a server or need to access any of its services remotely you can remove inetd.

4.2. lpd

lpd is used to print files on your printer using the lpr command. If you never print on your Linux box you can remove lpd. If, however, you own a HP Deskjet ™ printer and would like to print, I highly recommend the package I put together called dj-printcap which is available at:

ftp://sunsite.unc.edu/pub/Linux/system/Printing/dj-printcap.tar.gz

4.3. nfsd and mountd

These two daemons are used to run an NFS server. If you never use your Linux system as an NFS server you can safely remove these two daemons.

4.4. portmap

The portmap daemon is used to handle RPC services. If you do not run an NFS server or any other RPC programs you can remove portmap.

4.5. sendmail

sendmail is another daemon which requires a fair bit of memory. If you never use your Linux box as a relay for sending e-mail or you never receive mail on your Linux box, you can probably remove sendmail. If you do send e-mail from your Linux box most e-mail clients can be set-up to send e-mail from another mail server.

4.6. others

There may be other daemons your system starts up which you do not need. Remove what you feel you have to. Two daemons which you must run are syslogd and klogd.

Introduction

1. Introduction

Assuming buying more memory is out of the question there are many things you can do to tighten up memory usage in Linux.

Many Linux distributions out of the box are quite bloated from a memory perspective. They run more services and offer more features than most of us will ever need. By removing many of these services you can free up several megabytes of real memory.

My own system is a 486DX2-66 with 12MB of physical memory and 12MB of swap space. It has run Linux for the last 3 years quite happily, and hopefully it will run Linux for several more years. :)

Linux Kernel

2. Linux Kernel

All the Linux kernels which come with distributions are quite bloated and contain more features than any of us will ever need or use. If you have not re-compiled your own kernel, it is highly recommended that you do so. How to re-compile a kernel is beyond the scope of this document, but many excellent Linux books and guides cover this subject in intimate detail.

If you do re-compile your kernel, remember to put in no more features than you need. For instance: how many of you include PLIP support in your kernel? How many of you who include it actually use it? Smaller kernels require less time to load, use less memory, and use less CPU cycles.

Another thing is modules. I personally do not use them because I found them to be a cumbersome. If you use them and like them then they can help to relieve "kernel bloat."

Virtual Consoles

3. Virtual Consoles

VCs are a great way to free up memory. Most Linux distributions run about 6 of them out of the box. On average running 6 VCs requires about 4MB of memory. Removing a couple of them can free up a couple MBs of memory. Most users can get away with running only 3 or 4 VCs. How many you choose to remove is a matter personal preference. Just remember that the fewer you run, the more memory your applications will have to run.

The file which outlines how many VCs get loaded is /etc/inittab. In order to remove VCs:

  1. Load /etc/inittab in a text editor.

  2. Look for a line which looks like the following line (the key feature being a line which starts with c1):

    c1:12345:respawn:/sbin/getty tty1 38400
    					linux

    Start at the highest number (i.e. c6) and comment it out by inserting a '#' in the first row. Repeat this step as many times as needed. Remember every line you comment out is one less VC running.

  3. Re-boot the system for your changes to take effect.

GIF89a2-  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~!Copyright (c) 2000 Marco Budde,2-I Hz0֬Z"F@ŋ3jԸ FX IH(S4p$P .`ARN@A4QHW`E .^# 3h԰#C8"NClဌ[G ID&M8y%)TX%.]C̚7tji*WX*$& l`†pL1`XD M##H.eP,<<0 (~M.Eu$! 8ࠂ"$`$>!R5TrpX>]|IK'CSl1jqqB!܁8\tsQAE lC4Q_y2$k}"H ~q\\sńs|DbMqE[(Fo*PqHtBb\EއOlHqQL1ab|J|) h2gĚEDE(Db"oeDhE@ڦsNZ!M@!E`yEeG%d1*sM,xCK8lulzl iH<@ĦfBUf !P<o\D(ktoa9Fsq0lE@Ĵ7@9`DuYz,b)CrD@<+(D&rb`n ȁn@Ac&z60bc@8&~n 1@!я4E|&3QhWC".J8B8-Rq!t xľЀ``kPaqѭoC*2pB@"|a 2 QL bt.DxcA2b "$!eP?red(P&@PâxA i%.쁖`K'()#4@<oJbP: |C-%[ @SbyXЂDx Й ^A #` |'i ` # a H!{C 4!䐤>@`)+tJ_HP;"mWI$RC|Y 00 R0 (UC?aUfr~$wr oP` 5Aw8(=kYS:-}K0\M`j |!x@;`/BXY" p MUJVr`V%š_U \`DHhbE$t@4 ȉxYHC;mbién hay quien cree en los Reyes Magos.

4.7 Trucos y problemas

lpr -i o como modificar la impresión a nuestro antojo.

La opción -i envía argumentos al filtro de impresión. Ante todo, necesitamos un filtro instalado en printcap para que la opción '-i' funcione. Ésta se limita a pasar a través de lpd hacia el filtro. Si quisiera un filtro que permitiera configurar su impresora sobre la marcha, podríamos utilizar un filtro como este:

#!/bin/sh
# Mi programa de configuracion se llama confimpre.
exec /usr/lib/confimpre $* 

que desplace el margen izquierdo, y pasar como argumento el margen deseado.

#!/usr/bin/perl
# confimpre: Desplaza el margen izquierdo en un texto ascii
# Usamos perl porque convertir numeros a caracteres
# es un campo de minas en programacion shell
for  ( $i=0 ; !($_ = $ARGV[$i]) || !/^-i([0-9])+/;
$i++) {}
print pack( "cAc" , 27 , "l" , $1) ;
while (<STDIN>) { print; }

'lpc' y 'lpq' advierten : "missingdaemons"

Un proceso lpd corre continuamente, y se desdobla en hijos para manipular cada impresora en tanto se necesita. La salud del proceso principal no se manifiesta explícitamente con 'lpc'; basta con la ausencia de errores. El comando 'lpc stat' mostrará de manera normal el mensaje "no daemon present" para cada cola actualmente inactiva. Si la impresión se desactiva, o la cola se vacía, 'lpq' es bastante más escandaloso, gritando "Warning: no daemon present", aunque, de hecho, no hay condición de error. Si el demonio está ausente cuando hay entradas en la cola, y no ha sido explícitamente detenido, probablemente se debe a un fallo en algún filtro. Fíjelo y reinicie con "lpc up <cola>.

De vez en cuando, al desactivar una impresora, 'lpc' alucina, e intenta matar demonios inexistentes, emitiendo un surtido de irritantes e inofensivos mensajes de error. Esta "característica" es muy rara en versiones posteriores a lpd-590p2.

Impresión sobre red (notas adicionales)

Dado que la máquina que alberga la impresora física debe saber quien se conecta, deberemos dar de alta al resto de los ordenadores en los ficheros /etc/hosts.equiv y /etc/hosts.lpd, con sus nombres canónicos, o direcciones IP. Si no está seguro del nombre completo de una máquina, puede incluir todos sus alias conocidos.

Por motivos de seguridad, es preferible que las máquinas que sólo deban tener acceso a la impresora queden restringidas a /etc/hosts.lpd.

Si el servidor de impresión no ejecuta un sistema de impresión tipo BSD ( UnixWare, HP-UX versión 10 ,...), debería ser posible trabajar con él, teniendo en cuenta que los ficheros de autorización pueden variar notablemente, cambiando en cada sistema.

Si aún no puede imprimir sobre un sistema distinto, queda un as en la manga: simplemente use una orden remota, tal que rsh, rexec ...

# rsh rabano.huerta.net "lp -dlp" < fichero 

permitirá imprimir sobre un SYSV, desde nuestra pera.huerta.net.

4.8 Los filtros de impresión

Los filtros en UNIX, son meramente programas (y como tales deben tener permisos de ejecución) que leen la entrada estándar y escriben sobre la salida estándar, independientemente de su complejidad.

Los filtros de lpd lo son en el sentido que leen STDIN y escriben en STDOUT; su peculiaridad estriba en que deben asumir que la entrada estándar es un fichero de acceso aleatorio, sobre el que se pueden realizar operaciones con lseek().

Un filtro que interpreta PostScript nos servirá de ejemplo:

#!/bin/sh
/usr/bin/gs -q -dSAFER -dNOPAUSE -r?? -sDevice=? -sOutputFile=- - < /dev/null

La primera línea invoca al intérprete de comandos que lo interpretará. Podemos usar csh, bash, perl, tcl, etc...; va por gustos.

En la segunda línea usamos gs como filtro, indicando que la entrada es STDIN ( el guión del final ), y la salida, STDOUT (-sOutputFile=-). Lea la página de manual de 'gs' para más detalles.

Es buena práctica guardar los filtros de entrada en el directorio tampón de la impresora en la que se usan (o en /var/spool/lpd/ ), aunque las buenas maneras recomienden camas separadas para datos y programas.

Más difícil aún:

#!/bin/sh
/usr/tex/bin/dvips -f | /usr/bin/gs [...] -sOutputFile=- -

Como se puede ver, este filtro procesará un fichero texto de formato TEX o LATEX, obteniendo un fichero .dvi, que es transformado en PostScript, y reprocesado con ghostscript para imprimirlo en una impresora normal.

Ojo: Si usa impresión remota con lpr, el filtro deberá encontrarse en la máquina remota; LPRng obvia este inconveniente.

Los filtros de salida

Son como el goto en 'C', se pueden usar, pero realmente, es difícil encontrar aplicaciones para ellos. Dado que cualquier comando de iniciación de la impresora es ignorado, si tenemos un trabajo rodando que cambia algo (el tipo de letra, por ejemplo), el nuevo trabajo probablemente acabará mal impreso. No los use.

Depuración de filtros

Es absolutamente trivial: mifiltro <fichero >/dev/lp1 (como root). Comprobaremos de inmediato si de verdad funciona.

Un truco muy útil para los filtros con argumentos en línea de comandos consiste en incluir la línea

echo $* >> /tmp/filter-log

cerca del principio del guión. Recuerde incluir en la primera línea '#!/bin/sh', asegúrese de que el propietario es root, y que son ejecutables por todo el mundo.

Filtros Mágicos

Tienen de especial estos programas que son capaces de identificar la familia de los datos a imprimir a partir de patrones característicos de datos en situaciones determinadas. Son generalmente guiones Shell, Perl, programas en C ...; el programa identifica la fuente de datos, y llama a un filtro ordinario que lo procesa de modo adecuado. Con un filtro mágico adecuado y tres filtros no mágicos podemos imprimir cosas como esta:

# lpr -d fich1.dvi fich2.dvi.Z fich3.ps fich4.tex.gz

Un buen sitio para encontrar filtros mágicos como el del ejemplo anterior es:

ftp://tsx-11.mit.edu/pub/linux/sources/usr.bin/magic-filter-??.tar.gz.

Como podrá suponer, nunca se deberían usar como filtros de salida.

Un ejemplo: el siguiente filtro mágico identifica un fichero fuente ps o texto, y lo procesa de acuerdo a su clase:

#!/bin/sh
printf "<Filtro magico para imprimir texto y ps.>"
read first_line
first_two_chars=`expr $first_line : '\(..\)'`
if [ "$first_two_chars" = "%!" ] ; then # Documento PostScript.
/usr/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=??? -sOutputFile=- - < /dev/null
else 
# Texto llano - Si hace falta, podemos incluir aqui la
# correccion del efecto escalera
echo -n $first_line
cat
printf "\014"
fi

Para desazón de muchos, habrá ya notado que un script ejecutado por alguien distinto al propietario puede ser una brecha de seguridad. Este no es el caso de los filtros de lpd, ya que el entorno de los guiones no está al alcance de potenciales piratas.

Los usuarios de HP estamos de suerte

Hasta donde hemos podido averiguar, HP no tiene ningún programa que permita configurar sobre la marcha sus impresoras ( ni siquiera para sus propios sistemas UNIX!!), salvo que use MS-Windows, o *DOS; por lo que sólo nos queda, bien usar DOSEMU, o salir a DOS, configurar la impresora, y volver a Linux.

Existe un hermoso programa llamado hpmodeset Nota del Traductor:
Hay también otro programa más moderno y práctico, llamado hpset, localizable en cualquier mirror de Sunsite, en ../system/printing/
, escrito en Eiffel, que hace el trabajo por nosotros, muy fácil de usar. Su autor es Glenn Maughan ( glennm@insect.sd.monash.edu.au); se puede conseguir en ftp://hornet.sd.monash.edu.au/pub/hpmodeset/v2.0.

Permite fijar economode, definición, tipo de papel, etc... en ficheros PCL (el lenguaje de las impresoras HP) y ps. No es tan espectacular como el programa de windows, pero funciona muy bien, y es susceptible de ser utilizado como filtro de impresión.


Anterior Siguiente Indice