File: lg_tips14.html

package info (click to toggle)
lg-issue14 2-2
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 1,620 kB
  • ctags: 93
  • sloc: makefile: 30; sh: 3
file content (1338 lines) | stat: -rw-r--r-- 46,888 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> 
<html>
<head>
<title>More 2 Cent Tips & Tricks Issue 14</title>
</head>

<BODY BGCOLOR=#C0C0C0 TEXT=#000000 LINK=#0000FF VLINK=#0020F0
ALINK=#FF0000 BACKGROUND="../gx/spirbind.gif">
<table width=100%>
<tr><td><img src="../gx/blank.gif" width=50></td>
<td>
<H4>&quot;Linux Gazette...<I>making Linux just a little more lovable!</I>&quot;
<IMG ALIGN=MIDDLE SRC="../gx/heart.gif"> </H4>
<P> <hr> <P> 

<!-- QUICK TIPS SECTION ==================================================  -->
<center>
<H1><A NAME="tips"><IMG ALIGN=MIDDLE ALT="" SRC="../gx/twocent.gif">
More 2&#162; Tips!</A></H1> <BR>
Send Linux Tips and Tricks to <A HREF="mailto:gazette@ssc.com">
gazette@ssc.com
</A></center>

<p><hr><p>
<H3>Contents:</H3>
<ul>
<li><a HREF="./lg_tips14.html#quote">Backquote Warning</a>
<li><a HREF="./lg_tips14.html#bkgr">Browser Background Tip</a>
<li><a HREF="./lg_tips14.html#lower">Even Better Lowercasing of Filenames</a>
<li><a HREF="./lg_tips14.html#filter">Filtering Advertisements from WWW Tip</a>
<li><a HREF="./lg_tips14.html#less">Getting Less to View gzipped Files </a>
<li><a HREF="./lg_tips14.html#help">Help for Help on the Bash Shell</a>
<li><a HREF="./lg_tips14.html#caps">Lower Your Caps</a>
<li><a HREF="./lg_tips14.html#boot">Making Linux Boot Floppies</a>
<li><a HREF="./lg_tips14.html#xterm">More on Xterm Titlebar</a>
<li><a HREF="./lg_tips14.html#remind">Remind Tip</a>
<li><a HREF="./lg_tips14.html#scrip">Script to Call Your Editor</a>
<li><a HREF="./lg_tips14.html#web">Tip for Your Web Page</a>
<li><a HREF="./lg_tips14.html#title">Titlebar Tip</a>
<li><a HREF="./lg_tips14.html#heart">2 Bit Tip -- Heartbeat</a>
<li><a HREF="./lg_tips14.html#xdm">2 Cent Tip for xdm</a>
<li><a HREF="./lg_tips14.html#two">Two 2 Cent Tips -- syslog & X Color Depth</a>
<li><a HREF="./lg_tips14.html#depth">X Windows Depth</a>
</ul>

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="quote"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Backquotes Warning
</H3>
<P> 
Date: Tue, 14 Jan 1997 00:40:21 -0800
From: alan bailward <alan_bailward@mindlink.bc.ca>
<P> 
In the $0.02 tip for using the script 'swaplogs' the commands : 
<ty>cp /var/adm/messages /var/adm/messages.'date +%d' </ty>
uses the wrong quotes. 
The backquote not the forward quote has to be used here, to make
the *output* of the command part of the filename.
<P> 
alan
<blockquote> <I>
(Actually, the backquote is in the html. It's just that some Browser
fonts wont print a backquote -- in fact, mine doesn't. I'm not sure
how to get around this other than to warn people who are reading online.
If you print LG out, the quotes will be in the right direction. --Editor)
</I> </blockquote> 
 
<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="bkgr"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
WWW Background Tip
</H3>
<P> 
Date: Wed, 8 Jan 1997 12:23:03 -0500 (EST) <BR> 
From: Kurt M. Hockenbury, <A HREF="mailto:kmh@linux.stevens-tech.edu">
kmh@linux.stevens-tech.edu</A><BR> 
<P> 
I noticed people complaining about backgrounds making text unreadable.
Personally, I got tired of unreadable backgrounds, as well as large
image downloads, so I turned them off.  I also turned off those annoying
blink tags.
<P> 
How?  Add these two lines to your ~/.Xdefaults file.
<P> 
Netscape*documentColorsHavePriority: False  <BR> 
Netscape*blinkingEnabled: False
<P> 
In LG #13, Eje Gustafsson, gne@ffa.se writes:
<PRE> 
>>          1.mv /var/adm/messages /var/adm/messages.prev 
>>          2.touch /var/adm/messages 
>>          3.kill -1 pid-of-syslogd 
>>
>>       This should work on a decent Unix(like) system, and I know Linux 
>>is one of them. 
>
>This is NOT an proper way of truncate /var/adm/messages. 
>
>It is better to do: 
>
>  1.cp /var/adm/messages /var/adm/messages.prev 
>  2.>/var/adm/messages or cp /dev/null /var/adm/messages (both of them makes 
>the file empty). 
>  3.No more. 
</PRE> 
I'm sorry, but (at least on Linux) this is flat out _wrong_.
The first method (mv & HUP) is the correct method of truncating syslog files
(such as /var/adm/messages).
<P> 
Your method looses any messages that get syslog'd between steps 1 and 2; 
anything that comes in after the first cp gets overwritten when the second
cp happens.
<PRE> 
>The problem is that when you remove the /var/adm/messages syslogd gets
>confused and unhappy and you have to give syslogd a HUPSIG but if you
>just sets the file length to zero without removing the file syslogd
>don't complain. And if you are really unlucky your system will go down
>because you didn't create /var/adm/messages quick enough or forgot it.
</PRE> 
Not so.  mv'ing /var/adm/messages doesn't bother syslogd at all, as long
as you stay on the same partition.  In fact, you can 'mv
/var/adm/messages /var/adm/fish', and until syslogd is HUP'd or
otherwise restarted, it will keep logging in the file fish.  Try it if
you don't believe me - it's true!  That is because once syslogd has
open()d the file, it will keep writing to that file until it close()s it
- and a file in the Unix world is an inode, not a filename.  (As an
aside, this is how you can have the 100% full empty partition.  Even
though you unlink or rm a file, the file doesn't actually go away until
all programs that have it open close it.)
<P> 
syslogd doesn't get confused at all.  You can even rm /var/adm/messages, and
syslogd won't crash your system, though eventually the partition may fill
up with syslog messages you can't easily read since there isn't a filename
associated with the log file anymore.
<P> 
Kurt Hockenbury, Distributed Systems Administrator <BR> 
Stevens Institute of Technology


<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="lower"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Even Better Lowercasing of Filenames</H3>
<P> 
Date: Sun, 5 Jan 1997 19:17:16 -0800 (PST)
From: Greg Badros, <A HREF="mailto:gjb@cs.washington.edu">
gjb@cs.washington.edu </A> 
<P> 
It's even easier with zsh (3.0.x) to convert filenames to all-lowercase:
<PRE> 
for i in *(.); mv $i ${i:l}
</PRE> 
The *(.) uses a modifier on the wildcard to mean &quot;only regular files&quot;
(i.e., not directories).  And the ${i:l} converts the variable to
lowercase, so we don't have to use tr.
<P> 
This is not only shorter to type, but doesn't exec multiple programs (test
+ mv + tr)  for each file, and looks at fewer files since the shell
implicitly does the first test.
<P> 
Greg

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="filter"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Filtering Advertisements from Web Pages using WebFilter
</H3>
Date: Thu, 16 Jan 97 20:28:50 PST <BR> 
From: Axel Boldt, <A HREF="mailto:boldt@cardinal.math.ucsb.edu">
boldt@cardinal.math.ucsb.edu </A> 
<P> 
Hi,
In last month's Gazette, David Rudder wrote an article about <a
href="../issue13/filter.html">how to filter
advertisements from web pages using IPFWADM</a>, the idea being that
many ads come from the same site and it is easy to configure a Linux
firewall to refuse all connections from such a site.<p>

This approach has two disadvantages: you have to be root in order to
use the IPFWADM tool, and it allows you only to block entire sites.
Very often, you want to filter out only a specific ad residing on a
site, without blocking the rest of that site's material. Moreover,
different users of the Linux box might have different tastes when it
comes to ads.<p>

I believe that my tool WebFilter a.k.a. NoShit addresses these issues
and is better suited for filtering ads from specific web sites. The
idea is the following: the user runs WebFilter as a personal filtering
proxy server, and the browser contacts this proxy whenever it wants to
fetch a web document. The proxy then actually goes out and downloads
the page, checks whether any filterscripts apply to this page, and if
yes, pipes it through those scripts and returns the output to the
browser.  The mapping between URL and filterscript has to be provided
by the user in advance. A filterscript can be an arbitrary program
that reads the original document from standard input and produces the
filtered version on standard output. In practice, filterscripts are
most often short sed, awk, or perl scripts.<p>

If you often use sites such as Yahoo or Infoseek, you can easily write
filterscripts that excise the ads from their pages. This saves time,
money, and bandwidth.<p>

More information about WebFilter can be gotten from its <a
href="http://www.math.ucsb.edu/~boldt/NoShit/">homepage</a>. There
you'll also find links to other programs implementing the same idea.<p>

Have fun,<br>
Axel

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="less"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Getting less to View gzipped Files
</H3>
Date: 09 Jan 1997 20:18:58 -0600 <BR>
From: Alan Shutko, <A HREF="mailto:ats@wydo125.wustl.edu">
ats@wydo125.wustl.edu </A> 
<P> 
A little known ability of less is the ability to define filters when
it opens and closes files.  This excerpt from the man page deserves
broader attention, since it can easily be extended to other types.
<P> 
       For example, on many Unix systems, these two scripts  will
       allow  you  to  keep files in compressed format, but still
       let less view them directly:
<PRE> 
       lessopen.sh:
            #! /bin/sh
            case "$1" in
            *.Z) uncompress -c $1  >/tmp/less.$$  2>/dev/null
                 if [ -s /tmp/less.$$ ]; then
                      echo /tmp/less.$$
                 else
                      rm -f /tmp/less.$$
                 fi
                 ;;

                      Version 321: 18 Jul 96                   16

            esac

       lessclose.sh:
            #! /bin/sh
            rm $2
</PRE> 
       To use these scripts, put them both where they can be exe-
       cuted     and     set   <ty> LESSOPEN="lessopen.sh %s"</ty>,    and
       <ty>LESSCLOSE="lessclose.sh %s %s"</ty>.  More complex LESSOPEN and
       LESSCLOSE  scripts may be written to accept other types of
       compressed files, and so on.
<P> 
Alan Shutko 

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="help"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Help for Help on the Bash Shell
</H3>
Date: Tue, 14 Jan 1997 15:36:50 +0100 (NFT) <BR> 
From: <A HREF="mailto:fk5a005@math.uni-hamburg.de">
mailto:fk5a005@math.uni-hamburg.de </A> 
<P> 
you did hear about help for the bash.
if you invoke <ty>help for</ty> 
then you will get some help about for.
<P> 
Okay, you know that one.
But did you know you can see all the helps at once?
I did not know it.
Then I tried
<ty>help "$*"</ty> and what happend was: every help was shown!
Of course too much for one screen.
so I piped it to less: <ty>help "$*" |less</ty> is quite good.
But then I thought about having a search command with less.
possible? yes, just do a less -p word file to see it.
<P> 
So I put everything together and like I do often I created an alias:
<PRE> 
alias helpall="help '$*' | less -p "
</PRE> 
and tried it: beautiful, I might not need man bash all the times.
Try it yourself.
<P> 
Perhaps try <ty>helpall " let "</ty> to see a result.
<P> 
Have a nice and bright Linux-year!
<P> 
Matthias

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="caps"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Lower Your CAPS 
</H3>
Date: Sat, 25 Jan 1997 20:44:42 -0800 (PST) <BR> 
From: Peat Bakke, <A HREF="mailto:pb@europa.com">pb@europa.com</A> 
<P> 
	One of those little things that gets to me is unzipping DOS pkzipped
files.  All of the filenames are in all caps.  I'm not sure why it bugs me,
but it does.  Anyhow, here's a quick script that I've found useful to convert 
all the caps in a directory into lower case (rather nice when you've got one 
of those big, 200 file zips):
<PRE>
	#!/bin/tcsh
	foreach i (*)
	mv $1 `echo $1 | tr '[A-Z]' '[a-z]'`
</PRE> 
	A word to the wise -- this lowers ALL caps, so be careful with those
Makefiles and such.
<P> 
-Peat


<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="boot"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Making Linux Boot Floppies
</H3>
Date: Sun, 5 Jan 1997 18:40:49 -0800 (PST) <BR> 
From: Andy Kahn, <A HREF="mailto:kahn@vivian.cs.ucla.edu">
kahn@vivian.cs.ucla.edu </A><BR> 
<P> 
After reading Bill Duncan's excellent article in
<a href="../issue13/floppies.html">
issue #13</a>
on using and managing floppies in Linux, I figured I'd
toss in a 2-cent tip.
<p>
Here is a script I use to make emergency boot floppies
on my system (kernel v2.0.27).  The need arose when I
installed RedHat 4.0 for the first time and noticed
that the installation procedure doesn't automatically
prompt you to create boot floppies (Slackware does, and
chances are that RedHat will also in the next version).

<p>

<pre>
#!/bin/csh -f
#
# makebootfloppy v0.2
#
# DESCRIPTION:
# User friendly script (with lots of verbose messages) used to make
# Linux boot floppies, using the 2.x kernels.
#
# Formats, creates the file system, mounts the floppy, installs the Linux
# kernel, installs LILO, umounts floppy, and cleans up.
#
# (Webmaster's note: Be sure to replace the "^C" in the line below
#  with a real control-C character!  Sorry for the inconvenience ... )
#
stty intr ^C
set PATH=(/usr/sbin /sbin /bin /usr/bin)

# the generic floppy device (usually auto-detected)
set GENFLOPPY=/dev/fd0

# the low-level floppy device, used with fdformat.  this might be obsoleted
# on your system
set LLFLOPPY=/dev/fd0H1440

# a temporary mount point for your floppy.  make sure it has enough space
# to copy the kernel into
set MOUNTPOINT=/tmp/floppy

# boot
set BOOT=/boot/boot.b
set KERNEL=/boot/vmlinuz

# LILO label
set LABEL=linux


# here we go!
#############
echo -n Insert a blank floppy into the drive and hit return...
set FOO=$<

# Low-level formatting the floppy...
fdformat $LLFLOPPY

# Making file system on floppy...
mke2fs -c $GENFLOPPY

# Mount the floppy
mkdir $MOUNTPOINT >& /dev/null
mount $GENFLOPPY $MOUNTPOINT

# Copy the kernel to the floppy
cp $BOOT $MOUNTPOINT
cp $KERNEL $MOUNTPOINT

# Install lilo
echo image=$MOUNTPOINT/`basename $KERNEL` label=$LABEL | \
    lilo -C - -b $GENFLOPPY -i $MOUNTPOINT/boot.b -c -m $MOUNTPOINT/map

sync

# Unmount floppy
umount $MOUNTPOINT

# Deleting temporary mount point
rm -rf $MOUNTPOINT

echo All done.
</pre>

<p> <hr> <p>
There's currently no error handling, so if one
command fails, the remaining commands will fail as well.
Other than that, feel free to modify and use it as you
like.  If you have suggestions on better ways to do
something, I'd love to hear them.<br>
--Andy, kahn@cs.ucla.edu <BR> 

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="xterm"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
More on Xterm Titlebar Tip 
</H3>
Date: Wed, 15 Jan 1997 23:33:34 -0700 (MST) <BR> 
From: Michael J. Hammel, <A HREF="mailto:mjhammel@csn.net">
mjhammel@csn.net </A> 
<P> 
I got a lot of email about my tip, most confused by the use of
escape/control characters in the script.  Here is my response.
<PRE> 
> > Date: Sat, 21 Dec 1996 15:18:01 -0600
> > From: Roger Booth <Roger_Booth@crow.bmc.com>
> > To: Linux Journal Editor
> > 
> > The Jan97 Issue 33 of Linux Journal contained the "Linux Gazette Two Cent Tips". 
> > I was interested in the tip "X Term Titlebar Function". Although 
> > the text of the tip stated that the tip would work in ksh-based 
> > systems, I could not get it to work as shown. I think there are 
> > three problems. First, I think there are a few transcription 
> > errors in the script. Second, I believe the author is using 
</PRE> 
I don't think there were transcription problems.  I'm pretty sure
it was the way I sent it, however....
<PRE> 
> > embedded control characters and it was not obvious to me which 
> > character sequences are representations of control characters 
> > and which characters should be typed verbatim. Third, the 
</PRE> 
Yes, there were control and escape characters in the file.
This was a problem and many people wrote me to ask about it.
In the following lines:
<PRE> 
   ilabel () { echo -n "^[]1;$*^G"; }
   label () { echo -n "^[]2;$*^G"; }
</PRE> 
the characters &quot;^[&quot; are an escape character and the characters &quot;^G&quot; are a
CONTROL-G character.  In order to add these to your file (when you type it
in by hand) using vi you would type:
<P> 
<ty>   ^VESC</ty> - which means CTRL-SHIFT-V followed by the ESCAPE key 
<P> 
and
<P> 
<ty>   ^V^G</ty> - which means CTRL-SHIFT-V followed by CTRL-SHIFT-G 
<P> 
Note that in *this* email I didn't actually include the control or escape
characters - I simply used their ASCII equivalents.  Hopefully this isn't
too confusing.
<PRE> 
> > author uses a command-line option to the echo command which 
> > is not available on all Unix platforms.
</PRE> 
This is also a problem.  See below.
<PRE> 
> > I finally used the following script:
> > 
> >     if [ ${SHELL##/*/} = "ksh" ] ; then
> >         if [[ $TERM = x"term" ]] ; then
> >             HOSTNAME=`uname -n`
> >             label () { echo "\\033]2;$*\\007\\c"; }
> >             alias stripe='label $LOGNAME on $HOSTNAME - ${PWD#$HOME/}'
> >             cds () { "cd" $*; eval stripe; }
> >             alias cd=cds
> >             eval stripe
> >         fi
> >     fi
> > I don't use vi, so I left out that functionality.
</PRE> 
I tried this and various similar responses that were mailed directly to me.
It should work using the octal versions of the escape sequences, but I
couldn't get it to work.  My problem is that I use the label() function
from the command line at times to simply set the title bar to some 
arbitrary value and using the octal sequences didn't seem to work for me.
I'm not sure why, however.  I do believe that, sometime in the distant
past, I too used octal sequences to set the xterm title bar.  I've long
forgotten why I switched.
<PRE> 
> > The functional changes I made are all in the arguments to the 
> > echo command. The changes are to use \\033 rather than what 
> > was shown in the original tip as ^[, to use \\007 rather than 
> > ^G, and to terminate the string with \\c rather than use the 
> > option -n.
</PRE> 
All of these should work just fine in ksh.  Your observation that not all
shells accept &quot;echo -n&quot; is correct.  I often have to check which works and
then manually set the echo line to either use &quot;-n&quot; or to print a \c.  One
or the other will always work, depending on if the echo is a shell
builtin or an actual Unix command.
<PRE> 
> > On AIX 4.1, the command "echo -n hi" echoes "-n hi"; in other 
> > words, -n is not a portable command-line option to the echo 
> > command. I tested the above script on AIX 3.2, AIX 4.1, 
> > HPUX 9.0, HPUX 10.0, Solaris 2.4 and Solaris 2.5. I'm still 
> > trying to get Linux and my Wintel box mutually configured, 
> > so I haven't tested it on Linux.
</PRE> 
I don't use X on the AIX or HPUX boxes at work.  I just rlogin from my Sun
boxes.  However, both Solaris and Linux should work with the -n option if
you're using the echo shell builtin.  If not, the \c will probably be
required.  On my Linux box I type 
<PRE> 
   bash% type echo
</PRE> 
which reports
<PRE> 
   echo is a shell builtin 
</PRE> 
so I know which one I'm using.  Knowing this you can provide alternatives
within your .bashrc or .kshrc to determine which version of the echo line
to use.  This is true of any Unix platform on which you use ksh or bash
(I believe).
<PRE> 
> > I have noticed a problem with this script. I use the rlogin 
> > command to log in to a remote box. When I exit from the
> > remote box, the caption is not updated, and still shows the 
> > hostname and path that was valid just before I exited. I tried
> > adding
> > 
> >     exits () { "exit" $*; eval stripe; }
> >     alias exit=exits
> > 
> > and
> > 
> >     rlogins () { "rlogin" $*; eval stripe; }
> >     alias rlogin=rlogins
> > 
> > Neither addition updated the caption to the host/path 
> > returned to. Any suggestions?
</PRE> 
Add this right after the alias for cd in the original script:
<PRE> 
   rlogins () { "rlogin" $*; cds . }
	alias rlogin=rlogins
</PRE> 
Its a hack, but it works.  You have to use &quot;cds&quot; instead of the alias &quot;cd&quot;
or else the real cd gets used and the title bar won't change.  In case
anyone is wondering, the reason you enclose &quot;rlogin&quot; (or &quot;cd&quot; or &quot;vi&quot;) in 
double quotes in this script is so the function rlogins() will run the real 
rlogin and not get stuck recursively calling itself.  Neat, eh?
<P> 
Boy, this stuff could get confusing fast.  Maybe it wasn't such a good tip 
after all.  <g>
<P> 
Michael J. Hammel  

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="remind"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Remind Tip
</H3>
<P> 
Date: Mon, 20 Jan 97 15:42:04 PST <BR> 
From: <A HREF="mailto:jmy@gim.net">jmy@gim.net </A> 
<P> 
This is a nice little script wich I have made, it places reminders to
~/.tcshrc or whatever. I think it's very useful. To use it first place at
THE END OF ~/.tcshrc:
<PRE> 
\echo
echo "--------------------( R E M I N D E R S )--------------------"
echo "-------------------------------------------------------------";\echo
</PRE> 
Then use this script:
<PRE>  
------------------------------c-u-t--h-e-r-e-------------------------------
#!/bin/tcsh
# Nice little scipt that places reminders to the end of ~/.tcshrc or
whatever.
# Made by jmy@gim.net email if you like it!

echo Remind 1.0 by jmy@gim.net
if ($#argv == 0) then
echo Use like \'remind \<option\> \<Reminder message\>\'
echo Option is \'a\' for add , \'u\' for undo and \'r\' for remove, pretty
easy
huh..:\)
\echo
echo NOTE: IF YOU REMOVED A LINE YOU DIDN\'T MEAN TO REMOVE, USE UNDO\!
\echo
exit 666
endif
if ($argv[1] == a) then
cat ~/.tcshrc | awk '\!/-------\";\\echo/ { print }' >! /tmp/remind.$user
echo echo $argv[2-] >> /tmp/remind.$user
echo 'echo "-------------------------------------------------------------";\echo'
>> /tmp/remind.$user
cp ~/.tcshrc ~/.tcshrc.remind
rm -f ~/.tcshrc
mv /tmp/remind.$user ~/.tcshrc
echo Added reminder: $argv[2-]
else if ($argv[1] == r) then
cat ~/.tcshrc | grep -v "echo $argv[2-]" >! /tmp/remind.$user
cp ~/.tcshrc ~/.tcshrc.remind
rm -f ~/.tcshrc
mv /tmp/remind.$user ~/.tcshrc
echo Removed Reminders:
diff ~/.tcshrc ~/.tcshrc.remind | awk '$2 ~ /echo/ { print$3,$4,$5,$6,$7,$8,$9, 
$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25 }'
else if ($argv[1] == u) then
if (-e ~/.tcshrc.remind) then
mv ~/.tcshrc ~/.tcshrc.remtemp
mv ~/.tcshrc.remind ~/.tcshrc
mv ~/.tcshrc.remtemp ~/.tcshrc.remind
echo Undo completed
else
echo No undo file was found \(~/.tcshrc\)
endif
else
echo Error: invalid argument\(s\) run it with no argument for a short help
\echo
exit 666
endif
\echo
---------------------c-u-t--h-e-r-e--a-l-s-o------------------------------
</PRE> 
Dont forget to do a 'chmod a+x remind'
And NEVER place any new lines after the lines you placed in ~/.tcshrc
If you wan't to use it with some other shell it should just be like
changing the paths in the script. And yes, it maybe should have been alot
easier to put the reminders in a separat file, but i like this solution
i'ts alot cooler...and maybe it can show someone how awk works.



<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="scrip"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Script to Call Your Editor
</H3>
Date: Thu, 16 Jan 97 15:21:34 PST <BR> 
From: Gary Chambers, <A HREF="mailto:geecee@gwi.net">geecee@gwi.net</A>
<P> 
I just found the Linux Gazette...  Thankfully!  It has truly made using
Linux more fun.
<P> 
I use the Linux version of Marko Macek's FTE editor.  Since it is
comprised of a separate X and console version, I began to get
frustrated with having to manually specify a default editor.  Now,
wherever I can specify it (e.g. Pine), I use my edit script.  It also
provides similar functionality at the command line.
<P> 
I'm new to Linux, so there may be better ways of doing this.  I
submitted this for inclusion in your 2-cent tips (my favorite section).
<PRE>
#!/bin/bash

# Determine whether we're in X Windows and call the proper editor
#

if [ "$WINDOWID" = "" ]; then
	fte $1 $2 $3 $4 $5
else
	xfte $1 $2 $3 $4 $5
fi
</PRE> 
GeeCee, Gary Chambers 

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="web"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Tip for Your Web Page
</H3>
Date: Fri, 3 Jan 1997 17:26:14 -0500 (EST) <BR> 
From: Ben Boule, <A HREF="mailto:bouleb@rpi.edu">bouleb@rpi.edu</A><BR> 
<P> 
One cool tip that I have found useful is the following.
If you are running your web page on your own machine or have the 
directory on NFS, put the following in your .profile :
<P> 
cp ~/.netscape/bookmarks.html ~/public_html/bookmarks.html <BR> 
cp ~/lynx_bookmarks.html ~/public_html/bookmarks2.html
<P> 
Change for different browsers and server setups.
<P> 
Then you can link them on your web page, and they get updated every time
you log in, start a new xterm, etc...
<P> 
Of course, this assumes you don't care about other people looking at your 
bookmarks.  
<P> 
Later,<BR> 
Ben Boule

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="title"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Re: Titlebar Tip
</H3>
Date: Mon, 20 Jan 1997 18:40:38 +0200 (SAT)<BR> 
From: Christopher Gordon, <A HREF="mailto:chris@bayes.agric.za">
chris@bayes.agric.za </A> 
<P> 
Roger Booth sent in a corrected version of the Titlebar script. I found that 
in order to get this working on a Slackware distribution of Linux, using
the bash shell, further modifications were neccesary. The control characters
need one \ as opposed to \\. The &quot;echo&quot; command required an -e switch. The
&quot;if&quot; statement only needed one [] not two. Finally, the script needed to
check if &quot;bash&quot; was running or not. I also added a command to simplify the 
prompt. Here is the corrected script. It can be run using the source command.
<PRE> 
if [ ${SHELL##/*/} = "bash" ] ; then
         if [ $TERM = x"term" ] ; then
             HOSTNAME=`uname -n`
             label () { echo -e "\033]2;$*\007\c"; }
             alias stripe='label $LOGNAME on $HOSTNAME - ${PWD#$HOME/}'
             cds () { "cd" $*; eval stripe; }
             alias cd=cds
             eval stripe
             export PS1='\$ '
         fi
     fi           
</PRE> 
Standard disclaimers apply.           
<P> 
Regards, <BR> 
Christopher Gordon, <BR>  
Remote Sensing, Inst. for Soil, Climate and Water <BR> 
Pretoria, South Africa

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="heart"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Two Bit Tip -- Heartbeat
</H3>
Date: Wed, 22 Jan 1997 22:29:06 -0800 (PST) <BR> 
From: Kragen Sittler, <A HREF="mailto:kragen@netcom.com">kragen@netcom.com</A>
<PRE><H5> 
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1997-01-22 22:11 PST by <heartbeat@gentle>.
# Source directory was `/usr/local/heartbeat'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   2222 -rw-r--r-- README
#    102 -rw-r--r-- crontab
#    371 -rwxr-xr-x heartbeat
#    142 -r-xr-xr-x rc.heartbeat
#   1045 -rwxr-xr-x update.sessionid
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  echo 'WARNING: not restoring timestamps.  Consider getting and'
  echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
# ============= README ==============
if test -f 'README' && test X"$1" != X"-c"; then
  echo 'x - skipping README (file already exists)'
else
  echo 'x - extracting README (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'README' &&
Heartbeat package
X
My computer seems to crash often -- about once every ten days.  I've been
wanting to know when this happens, but since the computer is busily crashing,
it doesn't have time to tell me.  (I suspect this happens because of power
outages.)
X
So I wrote a simple heartbeat package, which would keep a record in the
filesystem when it was alive.  That way, I could look at this record when
the machine crashed and tell when and how long it had crashed.
X
So I wrote a few scripts and created a new user.  I named the heartbeat user 
'heartbeat'.  (I know it's not really kosher to have a nine-letter username, 
but the only thing that has problems with it so far is ls.)
X
heartbeat is the first script; it updates a file in /var/log/heartbeat.
X
Here's the meat of heartbeat.
X
X	#!/bin/sh
X	touch /var/log/heartbeat/"`cat /var/run/heartbeat.sid`"
X
/var/log/heartbeat should be writable and executable by the heartbeat user; 
you may want to use root.  heartbeat gets run once a minute on my
system, from the heartbeat's crontab:
X
*   *    *    *    *          /usr/local/heartbeat/heartbeat
X
(For some reason, my crond does not like whitespace before crontab entries.)
X
The name of the file it updates is taken from /var/run/heartbeat.sid.  (I'm
not sure /var/run is really an appropriate place to put this, but I couldn't
find a better place.)  This file should be readable and writable by the 
heartbeat user.
X
heartbeat.sid is updated at boot time by a Perl script called update.sessionid.
update.sessionid also puts some information in the file that heartbeat updates.
X
I run update.sessionid (as the heartbeat user) from /etc/rc.d/rc.M, just before
cron is started.
X
Here's the section from my rc.M:
X
X....
# 
# Update heartbeat sessionid.
# This helps us find out when there was a crash.
[ -x /etc/rc.d/rc.heartbeat ] && /etc/rc.d/rc.heartbeat
X
# Start crond (Dillon's crond):
X....
X
and here's /etc/rc.d/rc.heartbeat:
X
#!/bin/sh
# Update the heartbeat sessionid.
# This should be done before starting cron.
su heartbeat -c /usr/local/heartbeat/update.sessionid
X
Now, when I want to know when the machine crashed, I can look in 
/var/log/heartbeat for the times of system shutdowns -- planned or 
otherwise.
SHAR_EOF
  $shar_touch -am 0122221197 'README' &&
  chmod 0644 'README' ||
  echo 'restore of README failed'
  shar_count="`wc -c < 'README'`"
  test 2222 -eq "$shar_count" ||
    echo "README: original size 2222, current size $shar_count"
fi
# ============= crontab ==============
if test -f 'crontab' && test X"$1" != X"-c"; then
  echo 'x - skipping crontab (file already exists)'
else
  echo 'x - extracting crontab (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'crontab' &&
# MIN HOUR DAY MONTH DAYOFWEEK   COMMAND
*   *    *    *    *          /usr/local/heartbeat/heartbeat
SHAR_EOF
  $shar_touch -am 0122221197 'crontab' &&
  chmod 0644 'crontab' ||
  echo 'restore of crontab failed'
  shar_count="`wc -c < 'crontab'`"
  test 102 -eq "$shar_count" ||
    echo "crontab: original size 102, current size $shar_count"
fi
# ============= heartbeat ==============
if test -f 'heartbeat' && test X"$1" != X"-c"; then
  echo 'x - skipping heartbeat (file already exists)'
else
  echo 'x - extracting heartbeat (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'heartbeat' &&
#!/bin/sh
# script to continually update a file's timestamp, except when the machine
# is down
# 
# This should be put in a crontab to be run every minute, or five minutes,
# or whatever.
# 
# /var/run/heartbeat.sid contains a sessionid that is incremented at each
# bootup, and is suitable for use as a filename.
X
touch /var/log/heartbeat/"`cat /var/run/heartbeat.sid`"
SHAR_EOF
  $shar_touch -am 0122210097 'heartbeat' &&
  chmod 0755 'heartbeat' ||
  echo 'restore of heartbeat failed'
  shar_count="`wc -c < 'heartbeat'`"
  test 371 -eq "$shar_count" ||
    echo "heartbeat: original size 371, current size $shar_count"
fi
# ============= rc.heartbeat ==============
if test -f 'rc.heartbeat' && test X"$1" != X"-c"; then
  echo 'x - skipping rc.heartbeat (file already exists)'
else
  echo 'x - extracting rc.heartbeat (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'rc.heartbeat' &&
#!/bin/sh
# Update the heartbeat sessionid.
# This should be done before starting cron.
su heartbeat -c /usr/local/heartbeat/update.sessionid
SHAR_EOF
  $shar_touch -am 0122221197 'rc.heartbeat' &&
  chmod 0555 'rc.heartbeat' ||
  echo 'restore of rc.heartbeat failed'
  shar_count="`wc -c < 'rc.heartbeat'`"
  test 142 -eq "$shar_count" ||
    echo "rc.heartbeat: original size 142, current size $shar_count"
fi
# ============= update.sessionid ==============
if test -f 'update.sessionid' && test X"$1" != X"-c"; then
  echo 'x - skipping update.sessionid (file already exists)'
else
  echo 'x - extracting update.sessionid (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'update.sessionid' &&
#!/usr/bin/perl
# Update sessionid for heartbeat, creating new sessionid file.
# This should be run at boot time.
X
my $sessionidfile = "/var/run/heartbeat.sid";
my $heartbeatdir = "/var/log/heartbeat";
X
open SESSIONIDFILE, $sessionidfile or 
X   die "Couldn't open <$sessionidfile> for read";
X
my $sessionid = <SESSIONIDFILE>; close SESSIONIDFILE;
chomp $sessionid;
X
if ($sessionid !~ /^[a-zA-Z]*[0-9]{4,}$/) { $sessionid = "boot0000"; }
X
$sessionid ++;
X
open SESSIONIDFILE, ">$sessionidfile" or
X   die "Couldn't open <$sessionidfile> for write";
X
print SESSIONIDFILE "$sessionid\n";
close SESSIONIDFILE;
X
my $heartbeatfile = "$heartbeatdir/$sessionid";
X
open HEARTBEATFILE, ">$heartbeatfile" or
X   die "Couldn't open <$heartbeatfile> for write";
X
my $message = <<end_of_message
Heartbeat file created.  System status:
end_of_message
;
X
my $uptime = `/usr/bin/uptime`;
my $date = `/bin/date`;
X
print HEARTBEATFILE $message, $date, $uptime or 
X   die "Write to <$heartbeatfile> failed after open; fs full? stopped";
X
close HEARTBEATFILE;
X
Xexit 0;
SHAR_EOF
  $shar_touch -am 0122211997 'update.sessionid' &&
  chmod 0755 'update.sessionid' ||
  echo 'restore of update.sessionid failed'
  shar_count="`wc -c < 'update.sessionid'`"
  test 1045 -eq "$shar_count" ||
    echo "update.sessionid: original size 1045, current size $shar_count"
fi
exit 0
</H5> </PRE> 

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="xdm"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
2 Cent Tip for xdm
</H3>
Date: Sun, 5 Jan 1997 21:28:02 -0600 (CST) <BR> 
From: Andrew Dyer, <A HREF="mailto:adyer@Mcs.Net">adyer@Mcs.Net</A>
<P> 
here are several ways you can dress up an xdm login screen:
<ol>
<li> use the 'Xbanner' program available on sunsite
<li> run a program like xearth or xfishtank that writes to 
the X login screen background
<li> use a static image display program like 'xv' to put up a 
simple bitmap
</ol>
I use xv to put up an image - to do this add a line like the following to
the file /usr/X11R6/lib/X11/xdm/Xsetup_0 (at least that's where is is in
my system (Caldera)):
<P> 
/usr/X11R6/bin/xv -rmode 1 -nc 64 -quit /home/adyer/pics/arcade.bmp
<P> 
This line will run 'xv' to put the image file at the end of the command
line onto the background window in 'root tiled' mode, dithers the image to 
only use 64 colors (to preserve colormap slots on my 256 color display),
and tells xv to exit after doing this.
<P> 
Note that if you run a program like xearth it will continue to run
after you have started the session and will contiinue to run by default
until the session is exited.  See the 'xdm' man page for more details.
<P> 
!!!!!!!!!!!!!
!! WARNING !! 
!!!!!!!!!!!!!
<P> 
programs run by xdm are usually run as root, and so pose a potential
security risk if they are not specifically designed for this.  You have
been warned :-)
<P> 
Andrew M. Dyer 

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="two"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Two 2 Cent Tips -- syslog & X Color Depth
</H3>
Date: 13 Jan 1997 10:33:29 +0100 <BR> 
From: Marco Melgazzi, <A HREF="mailto:marco@techie.com">marco@techie.com </A>
<P> 
Dear sirs
<P> 
	Here's two 2c tips for your wonderful Linux Gazette. Note that all
the lines ending with \ have to be joined on one line.
<P> 
1. :::: Syslog fun (oh no, not again) :::::
<P> 
	Everybody seem to like to put a line like the following in their
syslog:
<PRE> 
	*.*  /dev/ttyx
</PRE> 
	this way every message is printed on an unused tty and the curious ( or
worried ) user can switch to it and see what's going on.
	This approach has a big advantage ( it doesn't use any system resource
) and a couple of disadvantages ( notably you have to switch to text mode
to read the messages and then you don't have scrollback ).
	So I have this little workaround: in /etc/syslog.conf put something
like
<PRE> 
	*.*			/var/adm/current_session_log
</PRE> 
	In rc.local or whatever file is called before starting syslog
<PRE> 
	/bin/cat /dev/null > /var/adm/current_session_log
</PRE> 
	In fvwm you can add something like this:
<PRE> 
Style "tail" NoTitle, NoHandles, Sticky, WindowListSkip
Style "tail" StaysOnTop, CirculateSkip

*GoodStuff 		S-Log 	telnet-sm.xpm   	Exec "rxvt" \
			rxvt -geometry 132x45-0+0 -sl 1200 -font fixed \
			-e tail -n 1200 -f /var/adm/current_session_log &
</PRE> 
	So when you press the goodstuff button named 'S-log' you get a big rxvt
with a nice scrollback buffer that displays exactly what's going on in the
system. If your linux system stays up for weeks at a time you'll probably
have to set up a CRON entry that trims this file every once in a while but
this is left as an exercise for the reader ;-)
<P> 
	To pop down the rxvt a simple Ctrl-C is more than enough. By the way,
this approach will surely save a lot of stress to the monitor electronics:
in fact switching from text mode to hires a) takes time b) involves quite a
lot of non-trivial adjustments in the monitor circuitry so it could likely
acceelerate its ageing process.
<P> 
2. ::::: How to use X with more than one color depth ::::::
<P> 
	I normally use X in 8bit ( since my board is not VRAM based 1152x864 at
70Hz slows down things considerably ) but, since when I hacked my XF86_S3
to let me use higher clocks in 16bit mode :), occasionally I need to switch
to the 16bits depth (notably when using the oh-so-amazing 'The Gimp').
<P> 
	Since leaving two servers up and running all the time via xdm seemed a
waste of memory, by tinkering with manual pages and articles from the net I
came up with a viable alternative.
<P> 
	Let me first tell you one thing: in this way, when the second server is
running, you get both :0 (in 8bit) that is managed by xdm and :1 that has
been started on-demand. Since I don't usually use :1 while I'm online I
didn't took the time to provide MIT-MAGIC-COOKIE authorization for it: this
is a thing you -should- do if you plan to use this on the net.
<P> 
	Here there are a couple of my scripts:
<PRE> 
::: ----------------------------------------------------------------
:::/usr/local/bin/1open16
::: ----------------------------------------------------------------
xinit ~/.x_rc_for_1_16  -- /usr/X11/bin/X16 :1 vt8 &

::: ----------------------------------------------------------------
:::/usr/X11/bin/X16
::: ----------------------------------------------------------------
#!/bin/sh
exec XF86_S3.new -bpp 16 ${@+"$@"}

::: ----------------------------------------------------------------
:::~/.x_rc_for_1_16
::: ----------------------------------------------------------------
#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $

userresources=$HOME/.Xresources_for_1_16
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

export PATH= .... path ....

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge -display :1 $sysresources &
fi

if [ -f $sysmodmap ]; then
    xmodmap -display :1  $sysmodmap &
fi

if [ -f $userresources ]; then
    xrdb -merge -display :1  $userresources &
fi

if [ -f $usermodmap ]; then
    xmodmap -display :1  $usermodmap &
fi

....
misc other variables
....

exec fvwm -f .fvwmrc_for_1_16

::: ----------------------------------------------------------------
::: in ~/.fvwmrc_for_1_16 I have this: I'm not sure this duplication
::: is necessary but in my configuration it is. YMMV
::: ----------------------------------------------------------------
Function "InitFunction"
    Exec    "I"     xrdb -display :1 -merge ~/.Xresources &
    Exec    "I"     xmodmap -display :1 ~/.Xmodmap &
	Module	"I"		GoodStuff
	Exec	"I"	    emacs &
EndFunction
</PRE> 
	In this way when you execute the 1open16 script you will get a 16bit
screen on :1 at the default resolution you put in your system XF86Config
for 16bit depth.
<P> 
	Things get a little more hairy if you want to open the new screen with
a different set of resolutions: unluckily ( I guess for security reasons )
XFree lets you use a new XF86Config -only- if you are root. So to play
Quake on :1 you have to do the following...
<PRE> 
::: ----------------------------------------------------------------
::: in ~/.fvwmrc ( this is nice for password requests, I use it all the
::: time, just put the word 'Password' in the rxvt that you need and use
::: the supplied style. I use it for going online, to access netscape &
::: other net stuff ( I'm paranoid so I created a user named -net- that
::: I use for all internet related stuff, I hate live-data trojans etc.)
::: you get the point.)
::: ----------------------------------------------------------------
Style "*Password" NoTitle, NoHandles, Sticky, WindowListSkip,StaysOnTop

::: in a menu entry
Exec	"Quake (normal)"		exec rxvt -fn \
	"-b&h-lucidatypewriter-medium-r-*-*-*-180-75-75-*-*-*-*" \
	-geometry 40x1+1-1 -T \"Quake Password" -e \
	su root -c "/home/marco/bin/qk" &

::: ----------------------------------------------------------------
::: /home/marco/bin/qk. The redundant su is needed if you plan to launch
::: this file from the command line too.
::: ----------------------------------------------------------------
cd /home/marco/quake
su -c "xinit ./xf86quake  -- /usr/X11/bin/X -bpp 8 :1 vt8 -xf86config \
	/home/marco/lib/XF86Config.quake"
</PRE> 

	Of course /home/marco/lib/XF86Config.quake will contain only the
resolution that I usually play quake at ( that is 400x300 or 512x384 ). In
this way you can play quake without hassless even if you usually run at
1000-or-so x 800-or-so at whatever depth. Now if only Linus released the
updated 1.06 xf86quake ;-) (in 1.01 you can't use a custom heap, you
have the fixed 8mb one :( ).
<P> 
	Hope you'll like these tips!
<P> 
		Marco Melgazzi 

<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="depth"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
X Windows Color Depth
</H3>
Date: Fri, 17 Jan 1997 08:38:20 -0500 (EST)<BR> 
From: Aaron B. Dossett, <A HREF="mailto:aarond@ewl.uky.edu">
aarond@ewl.uky.edu </A> 
<PRE><h5>
 >I have recently been messing with my x-server, and have managed
 >to get a depth of 16, ie 2^16 colors. This works
 >really nice with Netscape, but some programs (doom, abuse, and
 >other games) wont work with this many colors. Do
 >you know of a fix? I have tried to get X to support multiple
 >depths--to no avail. The man-page suggests that some
 >video cards support multiple depths and some don't. How do I know
 >if mine does.
</h5></PRE> 
 Well, if your video card has enough RAM and you've got enough modes defined
 in your XF86Config file then you can specify the bit depth from the command
 line.  If you have a link called X to the server then the command
<PRE> 
  X -bpp 8 or X -bpp 16 or X -bpp 24
</PRE> 
 can be used.  I like to alias the commands X8, X16, and X24 to the above.
 For this to work best you should have your XF86Config file setup so that 
 each mode uses the maximum resolution possible.
<P> 
 Aaron Dossett, aarond@ewl.uky.edu


<P> <hr> <P> 
<!--================================================================-->
<A HREF="./lg_toc14.html"><IMG SRC="../gx/indexnew.gif" ALT="[ TABLE OF 
CONTENTS ]"></A> <A HREF="../index.html"><IMG SRC="../gx/homenew.gif" 
ALT="[ FRONT PAGE ]"></A> <A HREF="lg_mail14.html"><IMG SRC="../gx/back2.gif" ALT=" Back "></A>
<A HREF="lg_bytes14.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>

<P> <hr> <P>
<h5>This page maintained by the Editor of <I>Linux Gazette</I>,
<A HREF="mailto: gazette@ssc.com">gazette@ssc.com</A><BR> 
Copyright &copy; 1997 Specialized Systems Consultants, Inc. </H5> 
<P> 
</td></tr></table>
</body> 
</html>