1.3 Modifying the '/etc/ttys' file
Before modifying this important configuration file, we will first perform a test.
Code:
$ mkdir temp ; cd temp
$ cp /etc/ttys .
$ ls -l
total 48
-rw-r--r-- 1 j65nko j65nko 22944 Feb 2 02:32 ttys
Having a copy in our
'temp' directory, we do the following:
Code:
$ sed -f ../sercon ttys >ttys
$ cat ttys
$ ls -l ttys
-rw-r--r-- 1 j65nko j65nko 0 Feb 2 02:38 ttys
Oops, that is clearly the wrong way. The file was truncated to 0.
Please do not blame
'sed' for this behaviour, because this is regular
'sh' behaviour, as explained by the OpenBSD
sh(1) man page:
Code:
....the command cmd < foo > foo will
open foo for reading and then truncate it when it opens it for
writing, before cmd gets a chance to actually read foo.
The proper way is to make a backup of the original, use the backup file as input for
'sed', and redirect the
'sed' output to the original file.
Code:
$ cp /etc/ttys ttys.orig
$ sed -f ../sercon ttys.orig >ttys
An unified
'diff' shows the differences:
Code:
$ diff -u ttys.orig ttys
--- ttys.orig Tue Feb 2 02:58:32 2010
+++ ttys Tue Feb 2 02:58:52 2010
@@ -16,8 +16,14 @@
ttyC9 "/usr/libexec/getty Pc" vt220 off secure
ttyCa "/usr/libexec/getty Pc" vt220 off secure
ttyCb "/usr/libexec/getty Pc" vt220 off secure
-tty00 "/usr/libexec/getty std.9600" vt220 off secure
-tty01 "/usr/libexec/getty std.9600" vt220 off secure
+# --- original ---
+# tty00 "/usr/libexec/getty std.9600" vt220 off secure
+# --- modified ---
+tty00 "/usr/libexec/getty std.9600" xterm on secure
+# --- original ---
+# tty01 "/usr/libexec/getty std.9600" vt220 off secure
+# --- modified ---
+tty01 "/usr/libexec/getty std.9600" xterm on secure
tty02 "/usr/libexec/getty std.9600" unknown off
tty03 "/usr/libexec/getty std.9600" unknown off
tty04 "/usr/libexec/getty std.9600" unknown off
$Id: Advanced-sed.xml,v 1.4 2010/02/02 02:28:13 j65nko Exp $
$Id: vbul-html.xsl,v 1.15 2010/01/16 00:58:03 j65nko Exp $