File: lg_tips13.html

package info (click to toggle)
lg-issue13 3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,056 kB
  • ctags: 114
  • sloc: makefile: 36; sh: 4
file content (1086 lines) | stat: -rw-r--r-- 39,636 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> 
<html>
<head>
<title>More 2 Cent Tips & Tricks Issue 13</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 fun!</I>
&quot;</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_tips13.html#free">Another 2cent Tip for LG</a>
<li><a HREF="./lg_tips13.html#console">Console Trick Follow-up</a>
<li><a HREF="./lg_tips13.html#gif">GIF Animations</a>
<li><a HREF="./lg_tips13.html#adm">How to close and reopen a new /var/adm/messages file</a>
<li><a HREF="./lg_tips13.html#admin">How to truncate /var/adm/messages</a>
<li><a HREF="./lg_tips13.html#infozip">Info-ZIP encryption code</a>
<li><a HREF="./lg_tips13.html#kernel">Kernel Compile Woes</a>
<li><a HREF="./lg_tips13.html#title">Letter 1 to LJ Editor re Titlebar</a>
<li><a HREF="./lg_tips13.html#more">Letter 2 to LJ Editor re Titlebar</a>
<li><a HREF="./lg_tips13.html#redial">PPP redialer script--A Quick Hack </a>
<li><a HREF="./lg_tips13.html#table">TABLE tags in HTML</a>
<li><a HREF="./lg_tips13.html#undelete">Text File undelete</a>
<li><a HREF="./lg_tips13.html#var">Truncating /var/adm/messages</a>
<li><a HREF="./lg_tips13.html#host">2c Host Trick</a>
<li><a HREF="./lg_tips13.html#tcsh">Use of TCSH's :e and :r Extensions</a>
<li><a HREF="./lg_tips13.html#notes">Various notes on 2c tips, Gazette 12</a>
<li><a HREF="./lg_tips13.html#howto">Viewing HOWTO Documents</a>
<li><a HREF="./lg_tips13.html#xaw">Xaw-XPM .Xresources troubleshooting tip</a>
<li><a HREF="./lg_tips13.html#xterm">Xterm Titlebar</a>
</ul>

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

</td> </tr> </table>
<a name="free"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Another 2cent Script for LG
</H3>
Date: Wed, 11 Dec 1996 23:34:58 +0100 <BR> 
From: Hans Zoebelein, <A HREF="mailto:zocki@goldfish.cube.net">
zocki@goldfish.cube.net</A><BR>
<P> 
Hello LG people,
<P> 
here comes a short script which will check from time to time
that there is enough free space available on anything
which shows up in mount (disks, cdrom, floppy...)
<P> 
If space runs out, a message is printed every X seconds 
to the screen and 1 mail message per filled device is fired up.
<P> 
Enjoy! <BR> 
Hans
<PRE> 
#!/bin/sh

# 
# $Id: lg_tips13.html,v 1.1.1.1 1997/09/14 15:01:38 schwarz Exp $
#

#
# Since I got mysterious error messages during compile when
# tmp files filled up my disks, I wrote this to get a warning 
# before disks are full.
#
# If this stuff saved your servers from exploding, 
# send praising email to zocki@goldfish.cube.net.
# If your site burns down because of this, sorry but I 
# warned you: no comps.
# If you really know how to handle sed, please forgive me :)
#

#
# Shoot and forget: Put 'check_hdspace &' in rc.local.
# Checks for free space on devices every $SLEEPTIME sec. 
# You even might check your floppies or tape drives. :)
# If free space is below $MINFREE (kb), it will echo a warning 
# and send one mail for each triggering device to $MAIL_TO_ME.
# If there is more free space than trigger limit again, 
# mail action is also armed again. 
#

# TODO: Different $MINFREE for each device. 
# Free /*tmp dirs securely from old junk stuff if no more free space.


DEVICES='/dev/sda2 /dev/sda8 /dev/sda9'		# device; your put disks here
MINFREE=20480					# kb; below this do warning
SLEEPTIME=10					# sec; sleep between checks
MAIL_TO_ME='root@localhost'			# fool; to whom mail warning


# ------- no changes needed below this line (hopefully :) -------

MINMB=0
ISFREE=0
MAILED=""
let MINMB=$MINFREE/1024 	# yep, we are strict :)

while [ 1 ]; do
	DF="`/bin/df`"
	for DEVICE in $DEVICES ; do
		ISFREE=`echo $DF | sed s#.\*$DEVICE" "\*[0-9]\*" "\*[0-9]\*" "\*## | sed s#" ".\*##`
		
		if [ $ISFREE -le $MINFREE ] ; then
			let ISMB=$ISFREE/1024
			echo  "WARNING: $DEVICE only $ISMB mb free." >&2
			#echo "more stuff here" >&2
			echo -e "\a\a\a\a"
			
			if [ -z  "`echo $MAILED | grep -w $DEVICE`" ] ; then 
				echo "WARNING: $DEVICE only $ISMB mb free.
(Trigger is set to $MINMB mb)" \
				| mail -s "WARNING: $DEVICE only $ISMB mb free!" $MAIL_TO_ME
				MAILEDH="$MAILED $DEVICE"
				MAILED=$MAILEDH
				# put further action here like cleaning 
				# up */tmp dirs...
			fi
		elif [ -n  "`echo $MAILED | grep -w $DEVICE`" ] ; then 
			# Remove mailed marker if enough disk space 
			# again. So we are ready for new mailing action.  
			MAILEDH="`echo $MAILED  | sed s#$DEVICE##`"
			MAILED=$MAILEDH
		fi
	done
	sleep $SLEEPTIME

done
</PRE> 
<P> <hr> <P> 
<!--================================================================-->

</td> </tr> </table>
<a name="console"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Console Trick Follow-up 
</H3>
Date: Wed, 27 Nov 1996 16:20:06 -0500 (EST)<BR> 
From: Elliot Lee, <A HREF="mailto:sopwith@cuc.edu">sopwith@cuc.edu </A><BR> 
<P> 
Just finished reading issue #12, nice work.
<P> 
A followup to the "Console Tricks" 2-cent tip: <BR> 
What I like to do is have a line in /etc/syslog.conf that says:
<PRE>  
*.*                                                     /dev/tty10
</PRE> 
that sends all messages to VC 10, so I can know what's going on whether in
X or text mode. Very useful IMHO.
<P> 
-- Elliot, http://www.redhat.com/

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

</td> </tr> </table>
<a name="gif"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
GIF Animations
</H3>
Date: Thu, 28 Nov 1996 20:41:22 -0600 (CST) <BR> 
From: Greg Roelofs, <A HREF="mailto:newt@pobox.com">newt@pobox.com </A> 
<P> 
I too thought WhirlGIF (Graphics Muse, issue 12) was the greatest thing
since sliced bread (well, aside from PNG) when I first discovered it, but
for creating animations, it's considerably inferior to Andy Wardley's
<A HREF="http://www.peritas.com/~abw/multigif.html">MultiGIF</A>.  The
latter can specify tiny sprite images as parts of the animation, not just
full images.  For my PNG-balls animation (see http://quest.jpl.nasa.gov/PNG/),
this resulted in well over a factor-of-two reduction in size (577k to 233k).
For another animation with a small, horizontally oscillating (Cylon eyes)
sprite, the savings was more than a factor of 20(!).
<P> 
MultiGIF is available as source code, of course.  (And I had nothing to do
with it, but I do find it darned handy.)
<P> 
Regards, <BR>
Greg Roelofs, http://pobox.com/~newt/ <BR> 
Newtware, Info-ZIP, PNG Group, U Chicago, Philips Research, ...        

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

</td> </tr> </table>
<a name="adm"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Re: How to close and reopen a new /var/adm/messages file
</H3>
Date: Thu, 05 Dec 1996 01:09:27 -0800 <BR> 
From: CyberTech, <A HREF="mailto:CyberTech@ns.cybertech.org">CyberTech@ns.cybertech.org</A><BR> 
<P> 
Regarding the posting in issue #12 of your gazette, how to backup the
current messages file & recreate, here is an alternative method...
<P> 
Place the lines at the end of this messages in a shell script
(/root/cron/swaplogs in this example).  Don't forget to make it +x! 
Execute it with 'sh scriptname', or by adding the following lines to
your (root's) crontab:
<PRE> 
# Swap logfiles every day at 1 am, local time
0 01 * * *       /root/cron/swaplogs
</PRE> 
The advantage to this method over renaming the logfile and creating a
new one is that in this method, syslogd is not required to be restarted.
<PRE> 
#!/bin/sh
cp /var/adm/messages /var/adm/messages.`date +%d-%m-%y_%T`
cat /dev/null >/var/adm/messages

cp /var/adm/syslog /var/adm/syslog.`date +%d-%m-%y_%T`
cat /dev/null >/var/adm/syslog

cp /var/adm/debug /var/adm/debug.`date +%d-%m-%y_%T`
cat /dev/null >/var/adm/debug
</PRE> 

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

</td> </tr> </table>
<a name="admin"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
How to truncate /var/adm/messages
</H3>
Date: Mon, 02 Dec 1996 16:47:20 +0100 <BR> 
From: Eje Gustafsson, <A HREF="mailto:gne@ffa.se">gne@ffa.se </A> <BR>
<PRE> 
>In answer to the question: 
>
>            What is the proper way to close and reopen a new >/var/adm/messages
>            file from a running system? 
>
>       Step one: rename the file. Syslog will still be writing in it >after renaming so you don't
>       lose messages. Step two: create a new one. After re-initializing >syslogd it will be used.
>just re-initialize. 
>
>          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. 
</PRE> 
This is NOT an proper way of truncate /var/adm/messages.
<P> 
It is better to do: <BR> 
<ol> 
<li>cp /var/adm/messages /var/adm/messages.prev
<li>&gt;/var/adm/messages or cp /dev/null /var/adm/messages
(both of them makes the file empty).
<li>No more.
</ol>
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. 
<P> 
Best of regards, <BR> 
Eje Gustafsson, System Administrator  <BR> 
THE AERONAUTICAL RESEARCH INSTITUTE OF SWEDEN  <BR> 

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

</td> </tr> </table>
<a name="infozip"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Info-ZIP encryption code
</H3>
Date: Thu, 28 Nov 1996 20:58:39 -0600 (CST) <BR> 
From: Greg Roelofs, <A HREF="mailto:newt@pobox.com">newt@pobox.com</A><BR> 
<P> 
This is a relatively minor point, but Info-ZIP's Zip/UnZip encryption
code is *not* DES as reported in Robert Savage's article (LG issue 12).
It's actually considerably weaker, so much so that Paul Kocher has pub-
lished a known-plaintext attack (the existence of which is undoubtedly
the reason PKWARE was granted an export license for the code).  While
the encryption is good enough to keep your mom and probably your boss
from reading your files, those who desire *real* security should look
to PGP (which is also based on Info-ZIP code, but only for compression).
<P> 
And while I'm at it, Linux users will be happy to learn that the upcoming
releases of UnZip 5.3 and Zip 2.2 will be noticeably faster than the cur-
rent publicly released code.  In Zip's case this is due to a work-around
for a gcc bug that prevented a key assembler routine from being used--Zip
is now 30-40% faster on large files.  In UnZip's case the improvement is
due to a couple of things, one of which is simply better-optimized CRC
code.  UnZip 5.3 is about 10-20% faster than 5.2, I believe.  The new ver-
sions should be released in early January, if all goes well.  And then...
we start working on multi-part archives. :-)
<P> 
Greg Roelofs, http://pobox.com/~newt/ <BR> 
Newtware, Info-ZIP, PNG Group, U Chicago, Philips Research, ...        

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

</td> </tr> </table>
<a name="kernel"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Kernel Compile Woes
</H3>
Date: Mon, 2 Dec 1996 21:35:29 +0400 (GMT-4)<BR> 
From: Duncan Hill, <A HREF="mailto:dhill@sunbeach.net">dhill@sunbeach.net</A><BR>
<P> 
Greetings.  Having been through hell after a recompile of my kernel, I
thought I'd pass this on.  
<P> 
It all started with me compiling a kernel for JAVA binary support..who
tell me do that. Somehow I think I got experimental code in..even worse :>
Anyway, it resulted in a crash, and I couldn't recompile since then.
<P> 
Well, after several cries for help, and trying all sorts of stuff, I
upgraded binutils to 2.7.0.3, and told the kernel to build elf support and
in elf format, and hey presto.  I'd been wrestling with the problem for
well over a week, and every time, I'd get an error.  Unfortunately, I had
to take out sound support, so I'm going to see if it'll add back in.
<P> 
I have to say thank you to the folks on the linux-kernel mailing list at
vger.rutgers.edu.  I posted there once, and had back at least 5 replies in
an hour.  (One came back in 10 minutes).
<P> 
As for the LG, it looks very nice seen thru Lynx 2-6 (no graphics to get
messed up :>)  I love the Weekend Mechanic, and the 2 cent tips mainly.
Perhaps one day I'll contribute something,.
<P> 
Duncan Hill, Student of the Barbados Community College
http://www.sunbeach.net/personal/dhill/dhill.htm 
http://www.sunbeach.net/personal/dhill/lynx/lynx-main.html

<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">
Letter 1 to the LJ Editor re Titlebar
</h3>
Date: Sat, 21 Dec 1996 15:18:01 -0600 <br>
From: Roger Booth, <a
href="mailto: Roger_Booth@crow.bmc.com">Roger_Booth@crow.bmc.com</a><br>
To: linux@ssc.com

The Jan97 Issue 33 of <i>Linux Journal</i> 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 
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 
author uses a command-line option to the echo command which 
is not available on all Unix platforms.
<p>
I finally used the following script:
<pre>
    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
</pre>
I don't use vi, so I left out that functionality.
<p>
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.
<p>
On AIX 4.1, the command &quot;echo -n hi&quot; echoes &quot;-n hi&quot;; 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.
<p>
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
<pre>
    exits () { "exit" $*; eval stripe; }
    alias exit=exits
</pre>
and
<pre>
    rlogins () { "rlogin" $*; eval stripe; }
    alias rlogin=rlogins
</pre>
Neither addition updated the caption to the host/path 
returned to. Any suggestions?
<p>
Roger Booth, rbooth@bmc.com

<p><hr><p> 
<!--================================================================-->

</td> </tr> </table>
<a name="more"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>

<h3><img align=bottom alt=" " src="../gx/lil2cent.gif">
Letter 2 to the LJ Editor re Titlebar
</h3>
Date: Fri, 13 Dec 1996 23:03:37 -0700 (MST)
From: Gary Masters, <A HREF="mailto:gmasters@csn.net">gmasters@csn.net</A><BR>
<P> 
Some further clarification is needed with respect to the X Term Titlebar
Function tip in the Linux Gazette Two Cent Tips column of the January
1997 issue.  With regard to the -print option to find, Michael Hammel
says, &quot;Linux does require this.&quot; This is yet another example of &quot;Your
mileage may vary.&quot; Some versions of Linux do not require the -print
option.  And, although Solaris may not, SunOS 4.1.3_U1 and 4.1.4 do
require the -print option.  Also, if running csh or tcsh, remember to
escape wildcards in the file specification ( e.g. find ./ -name \*txt\* )
so that the shell doesn't attempt to expand them.  
<P> 
Second, for those tcsh fans out there, here is an xterm title bar function
for tcsh.
<P> 
NOTE:  This works on Slackware 3.0 with tcsh version 6.04.00, under the
tab, fv, and OpenLook window managers. Your mileage may vary.
<pre>
if ( $TERM == xterm ) then
  set prompt="%h> "
  alias cwdcmd 'echo -n "^[]2;`whoami` on ${HOST} - $cwd^G^[]1;${HOST}^G"'
  alias vi 'echo -n "^[]2;${HOST} - editing file-> \!*^G" ; vim \!* ;
cwdcmd'
  alias telnet '/bin/telnet \!* ; cwdcmd'
  alias rlogin '/usr/bin/rlogin \!* ; cwdcmd'
  cwdcmd
else
  set prompt="[%m]%~% "
endif
</PRE> 
<ol>
<li>Check to see if tcsh is running in an xterm.
<li>Set the prompt to show the current history event number.
<li>Set the alias cwdcmd to display the user, host, and current path in
    the xterm title bar, and set the icon name to the host name.  cwdcmd
    is a special tcsh alias, which if set holds a command that will be
    executed after changing the value of $cwd. 
<li>Set a vi alias to display the user, host, and file name under edit in
    the xterm title bar.  And run cwdcmd on exit to restore the xterm
    title bar and icon name.
<li>Alias telnet and rlogin to restore the xterm title bar and icon name 
    upon exit.  NOTE: Paths to telnet and rlogin may vary.
<li>Run the alias cwdcmd to set the initial xterm title bar and icon name.
<li>If this wasn't an xterm, set the prompt to show hostname and path.
</ul>
Gary Masters

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

</td> </tr> </table>
<a name="redial"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
PPP redialer script--A Quick Hack 
</H3>
Date: Sun, 08 Dec 1996 13:20:25 +0200 <BR> 
From: Markku J. Salama, <A
HREF="mailto:msalama@usa.net">msalama@usa.net</A><BR>
<P> 
This here is the way I do it, but don't use it if your area has some
regulations
about redialing the same phone numbers over and over:
<PRE> 
#!/bin/sh

# A quick hack for redialing with ppp by <root@superfly.salama.fi>
# Tries 2 numbers sequentially until connected
# Takes 1 cmdline parm, the interface (ppp0, ppp1...)

# You need 2 copies of the ppp-on script (here called modemon{1,2}) with 
# different telephone numbers for the ISP. These scripts should be
slightly 
# customized so that the passwd is _not_ written in them, but is taken
# separately from the user in the main (a.k.a. this) script. 

# Here's how (from the customized ppp-on a.k.a. modemon1):
# ...
# TELEPHONE=your.isp.number1 # Then make a copy of this script ->
modemon2 
			     # and change this to your.isp.number2
# ACCOUNT=your.account  
# PASSWD=$1                  # This gets the passwd from the main
script.
# ...

# /sbin/ifconfig must be user-executable for this hack to work.
 
wd1=1                                                   # counter start
stty -echo                                              # echo off
echo -n "Password: "                                    # for the ISP
account
read wd2
stty echo                                               # back on
echo                                                    
echo "Trying..."                                        
echo 'ATE V1 M0 &K3 &C1 ^M' > /dev/modem                # modem init, 
                                                        # change as
needed
                                                        
/usr/sbin/modemon1 $wd2                                 # first try
flag=1                                                  # locked

while [ 1 ]; do                                         # just keep on
going

       if [ "$flag" = 1 ]; then                         # locked?

              bar=$(ifconfig | grep -c $1)        # check for a link

              if [ "$bar" = 1 ]; then                   # connected?
                     echo "Connected!"                  # if so, then
                     exit 0                             # get outta here
              else
                     foo=$(ps ax)                       # already
running?
                     blaat=$(echo $foo | grep "/usr/sbin/pppd") 

                     if [ "$blaat" = "" ]; then         # if not, then
                            flag=0                      # unset lock
                     fi
              fi

       else                                             # no lock, ready
                                                        # to continue
              wd1=$[wd1+1]                              
              echo "Trying again... $wd1"

              if [ $[wd1%2] = 1 ]; then                 # this modulo
test
                     /usr/sbin/modemon1 $wd2            # does the
switching
              else                                      # between the 2
numbers
                     /usr/sbin/modemon2 $wd2            # we are using
              fi                                        

              flag=1                                    # locked again
                                                        
       fi

done                                                    # All done!
</PRE> 
There. Customize as needed & be an excellent person. Ant DON'T break any 
laws if redialing is illegal in your area!
<P> 
Mark

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

</td> </tr> </table>
<a name="table"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
TABLE tags in HTML
</H3>
Date: Fri, 20 Dec 1996 11:51:22 -0500 <BR> 
From: Michael O'Keefe,  <A HREF="mailto:Michael.OKeefe@LMC.Ericsson.SE">
Michael.OKeefe@LMC.Ericsson.SE </A> <BR>
Organization: Ericsson Research Canada <BR> 
<P> 
G'day,
<P> 
Just browsing through the mailbox, and I noticed your reply to a user
about HTML standard compliance and long download times. You replied that
you use the spiral image (a common thing these days) inside a &lt;TABLE&gt;.
<P> 
I hope you are aware that a browser cannot display any contents of a 
&lt;TABLE&gt; until it has received the &lt;/TABLE&gt; tag (no matter what version
of any browser - it is a limitation of the HTML tag) because the browser
cannot run its algorithm until it has received all of the &lt;TR&gt; and 
&lt;TD&gt; tags, and it can't be sure of that until the &lt;/TABLE&gt; tag comes
through. I have seen many complex sites, using many images (thankfully
they at least used the HEIGHT and WIDTH tags on those images to tell
the browser how big the image will be so it didn't have to download
it to find out) but still, putting it in a table nullifies much of the
speediness that users require. 
<P> 
A solution I often offer the HTML designers under me is to use a
&lt;DL&gt;&lt;DD&gt; combination. Though this doesn't technically fit the HTML DTD
(certain elements are not allowed in a &lt;DL&gt;) and I use an editor that
will not allow illegal HTML, so I can't do it myself (without going 
via a backdoor - but that's bad quality in my opionion). The downside
of the this is of course that you don't know what sized FONT the user
has set on the browser, and the FONT size affects the indetation width
of the &lt;DD&gt; element. But if your spiral image is not too wide, then 
that could be made a NULL factor. The plus to the &lt;DL&gt;&lt;DD&gt; is that the
page can be displayed instantly as it comes down (again..providing the
developer uses the HEIGHT and WIDTH attributes on *ALL* images so that
the browser doesn't have to pause it's display to get the image and work 
out how to lay out around the image)
<p>
Michael O'Keefe  

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

</td> </tr> </table>
<a name="undelete"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Text File undelete
</H3>
Date: Sat, 7 Dec 1996 15:00:58 +1300 (NZDT) <BR> 
From: Michael Hamilton, <A HREF="mailto:michael@actrix.gen.nz">
michael@actrix.gen.nz </A> <BR> 
<P> 
Here's a trick I've had to use a few times.
<P> 
Desperate person's text file undelete.
<P> 
If you accidentally remove a text file, for example, some email, or
the results of a late night programming session, all may not be lost.
If the file ever made it to disk, ie it was around for more than 30
seconds, its contents may still be in the disk partition.
<P> 
You can use the grep command to search the raw disk partition for the
contents of file.  
<P> 
For example, recently, I accidentally deleted a piece of email.
So I immediately ceased any activity that could modify that partition:
in this case I just refrained from saving any files or doing any compiles
etc.  On other occasions, I've actually gone to the trouble of bring the
system down to single user mode, and unmounted the filesystem.
<P> 
I then used the egrep command on the disk partition:  in my case the email
message was in /usr/local/home/michael/, so from the output from df,
I could see this was in /dev/hdb5
<PRE> 
  sputnik3:~ % df
  Filesystem         1024-blocks  Used Available Capacity Mounted on
  /dev/hda3              18621    9759     7901     55%   /
  /dev/hdb3             308852  258443    34458     88%   /usr
  /dev/hdb5             466896  407062    35720     92%   /usr/local

  sputnik3:~ % su
  Password:
  [michael@sputnik3 michael]# egrep -50 'ftp.+COL' /dev/hdb5 > /tmp/x
</PRE> 
Now I'm ultra careful when fooling around with disk partitions, so I
paused to make sure I understood the command syntax BEFORE pressing
return.  In this case the email contained the word 'ftp' followed by
some text followed by the word 'COL'.  The message was about 20 lines
long, so I used -50 to get all the lines around the phrase.  In the
past I've used -3000 to make sure I got all the lines of some source
code.  I directed the output from the egrep to a different disk
partition - this prevented it from over writing the message I was
looking for.
<P> 
I then used strings to help me inspect the output
<PRE> 
  strings /tmp/x | less
</PRE> 
Sure enough the email was in there.  
<P> 
This method can't be relied on, all, or some, of the disk space may
have already been re-used.  
<P> 
This trick is probably only useful on single user systems.  On
multi-users systems with high disk activity, the space you free'ed up
may have already been reused.  And most of use can't just rip the box
out from under our users when ever we need to recover a file.
<P> 
On my home system this trick has come in handy on about three
occasions in the past few years - usually when I accidentally trash
some of the days work.  If what I'm working survives to a point where
I feel I made significant progress, it get's backed up onto floppy, so
I haven't needed this trick very often.
<P> 
Michael

 <p><hr><p> 
<!--================================================================-->

</td> </tr> </table>
<a name="var"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>

<h3><img align=bottom alt=" " src="../gx/lil2cent.gif">
Truncating /var/adm/messages
</h3>
Date: Tue, 31 Dec 1996 15:32:57 GMT+100 <BR> 
From: Michel Vanaken, <A HREF="mailto:michel@idtech.be">michel@idtech.be</A><BR>
Organization: IDtech <BR> 
<P> 
Hi !
<P> 
About the topic &quot;How to truncate /var/adm/messages&quot;, here's the way 
to do it with a shell script :
<pre>
mv /var/adm/messages /var/adm/messages.prev
touch /var/adm/messages
mv /var/adm/syslog /var/adm/syslog.prev
touch /var/adm/syslog
kill -1 `ps x | grep syslog | grep -v grep | awk '{ print $1 }'`
</pre>
Happy new year ! <BR> 
Michel

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

</td> </tr> </table>
<a name="host"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
2c Host Trick
</H3>
Date: Tue, 10 Dec 1996 17:27:46 +0300 <BR> 
From: Paul Makeev, <A HREF="mailto:mac@rosprint.ru">mac@rosprint.ru</A><BR> 
<P> 
In order to make DHCPD by ISC/Vixie to run under Linux, you should
have route to host 255.255.255.255. Standard "route" from Slackware
distribution does not like the string "route add -host 255.255.255.255
dev eth0". But you can add hostname to your /etc/hosts file with
address 255.255.255.255, and use "route add hostname dev eth0" instead.
It works.
<P> 
Paul.

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

</td> </tr> </table>
<a name="tcsh"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Use of TCSH's :e and :r Extensions
</H3>
Date: Mon, 02 Dec 1996 23:25:23 -0500 <BR> 
From: Bill C. Riemers, <A HREF="mailto:bcr@feynman.com">bcr@feynman.com</A><BR> 
<P> 
I'd like to congratulate Jesper Pedersen on his article on tcsh
tricks.  Tcsh has long been my favorite shell.  But most of the features
Jesper hit upon are also found in bash.  Tcsh's most useful and unique
features are its variable/history suffixes.
<P> 
For example, if after applying a patch one wishes to undo things, by
moving the *.orig files to there base names, the :r extension which
means to strip the extension comes in handy.  e.g.
<PRE> 
 foreach a ( *.orig )
    mv $a $a:r
 end
</PRE> 
The same loop for ksh looks like:
<PRE> 
  for a in *.orig; do=20
    mv $a `echo $a|sed -e 's,\.orig$,,g'`
  done
</PRE> 
Even better, one can use the :e extension to extract the file extension.
For example, lets say we we want to do the same thing on compressed
files:
<PRE> 
  foreach a ( *.orig.{gz,Z} )
    mv $a $a:r:r.$a:e
  end
</PRE> 
The $a:r:r is the filename without .orig.gz and .orig.Z,  we tack the
.gz or .Z back on with .$a:e.
<P> 
Bill

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

</td> </tr> </table>
<a name="notes"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Various notes on 2c tips, Gazette 12
</H3>
Date: Wed, 04 Dec 1996 15:30:21 -0600 <BR> 
From: Justin Dossey, <A HREF="mailto:dossey@ou.edu">dossey@ou.edu </A> <BR>
<P> 
I noticed a few overly difficult or unnecessary procedures recommended
in the 2c tips section of Issue 12.  Since there is more than one, I'm
sending it to you:
<PRE> 
#!/bin/sh
         # lowerit
         # convert all file names in the current directory to lower case 
         # only operates on plain files--does not change the name of
directories
         # will ask for verification before overwriting an existing file
         for x in `ls`
           do
           if [ ! -f $x ]; then
             continue
             fi
           lc=`echo $x  | tr '[A-Z]' '[a-z]'`
           if [ $lc != $x ]; then
             mv -i $x $lc
           fi
           done
</PRE> 
Wow.  That's a long script.  I wouldn't write a script to do that;
instead, I would use this command:
<PRE> 
for i in * ; do [ -f $i ] && mv -i $i `echo $i | tr '[A-Z]' '[a-z]'`;
done;
</PRE> 
on the command line.
<P> 
The contributor says he wrote the script how he did for
understandability (see below).
<P> 
On the next tip, this one about adding and removing users, Geoff is
doing fine until that last step.  Reboot?  Boy, I hope he doesn't reboot
every time he removes a user.  All you have to do is the first two
steps.  What sort of processes would that user have going, anyway?  An
irc bot?  Killing the processes with a simple 
<PRE> 
kill -9 `ps -aux |grep ^<username> |tr -s " " |cut -d " " -f2`
</PRE> 
Example, username is foo
<PRE> 
kill -9 `ps -aux |grep ^foo |tr -s " " |cut -d " " -f2`
</PRE> 
That taken care of, let us move to the forgotten root password.
<P> 
The solution given in the Gazette is the most universal one, but not the
easiest one.  With both LILO and loadlin, one may provide the boot
parameter &quot;single&quot; to boot directly into the default shell with no login
or password prompt.  From there, one may change or remove any passwords
before typing ``init 3``to start multiuser mode.  
Number of reboots: 1
The other way
Number of reboots: 2
<P> 
That's just about it.  Thanks for the great magazine and continuing
contribution to the Linux community.  The Gazette is a needed element
for many linux users on the 'net.
<P> 
Justin Dossey
<P> 
Date: Wed, 4 Dec 1996 08:46:24 -0800 (PST) <BR> 
Subject: <B> Re: lowerit shell script in the LG </B> <BR> 
From: Phil Hughes, <A HREF="mailto:phil@ssc.com">phil@ssc.com </A> <BR> 
<P> 
The amazing Justin Dossey wrote:
<PRE> 
> #!/bin/sh
> for i in * ; do [ -f $i ] && mv -i $i `echo $i | tr '[A-Z]' '[a-z]'`;
> done;
> 
> may be more cryptic than 
...
> 
> but it is a lot nicer to the system (speed & memory-wise) too.
</PRE> 
Can't argue.  If I had written it for what I considered a high usage
situation I would have done it more like you suggested.  The intent,
however, was to make something that could be easily understood.
<P> 
Phil Hughes

 <p><hr><p> 
<!--================================================================-->

</td> </tr> </table>
<a name="howto"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>

<h3><img align=bottom alt=" " src="../gx/lil2cent.gif">
Viewing HOWTO Documents
</h3>
Date: Sun, 22 Dec 1996 09:43:40 -0800 <br>
From: Didier Juges, <a
href="mailto:dj@destin.nfds.net">dj@destin.nfds.net</a><br>
<p>
>From a newbie to another, here is a short script that eases looking for 
and viewing howto documents.
My howto's are in /usr/doc/faq/howto/ and are gzipped. The file names are 
XXX-HOWTO.gz, XXX being the subject.
I created the following script called "howto" in the /usr/local/sbin 
directory:
<pre>
#!/bin/sh
if [ "$1" = "" ]; then
    ls /usr/doc/faq/howto | less
else
    gunzip -c /usr/doc/faq/howto/$1-HOWTO.gz | less
fi
</pre>
When called without argument, it displays a directory of the available 
howto's. Then when entered with the first part of the file name (before 
the hyphen) as an argument, it unzips (keeping the original intact) then 
displays the document.
<p>
For instance, to view the Serial-HOWTO.gz document, enter:
$ howto Serial
<p>
Keep up the good work.
<p>
Didier

 <p><hr><p> 
<!--================================================================-->

</td> </tr> </table>
<a name="xaw"><p></a>
<table>
<td><img src="../gx/blank.gif" width=50></td>
<td>

<h3><img align=bottom alt=" " src="../gx/lil2cent.gif">
Xaw-XPM .Xresources troubleshooting tip.
</h3>
Date: Wed, 18 Dec 1996 17:02:07 +0100 (GMT+0100) <br>
From: Robin Smidsroed, <a
href="mailto:dex@sysedata.no">dex@sysedata.no</a><br>
<p>
I'm sure a lot of you folks out there have installed the new Xaw-XPM and
like it a lot. But I've had some trouble with it. If I don't install the
supplied .Xresources-file, xcalc and some other apps (ghostview is one)
segfaults whenever you try to use them.
<p>
I found out that the entry which causes this, is this:
<pre>
*setPixmap: /path/to/an/xpm-file
</pre>
If this entry isn't in your .Xresources, xcalc and ghostview won't work. Hope
some of you out there need this.
<p>
And while you're at ghostview, remember to upgrade ghostscript to the latest
version to get the new and improved fonts, they certainly look better on
paper than the old versions.
<p>
Ciao! <br>
Robin
<p>
PS: Great mag, now I'm just waiting for the arrival of my copy of LJ

 <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">
xterm title bar
</h3>
Date: Wed, 18 Dec 1996 21:21:47 -0800 (PST)
From: bradshaw@nlc.com (Lee Bradshaw)
<p>
Hi Guys,
<p>
I noticed the &quot;alias for cd xterm title bar tip&quot; from Michael
Hammel in
the <i>Linux Gazette</i> and wanted to offer a possible improvement for your
.bashrc file.  A similar solution might work for ksh, but you may need
to substitute $HOSTNAME for \h, etc:
<pre>
if [ "x$TERM" = "xxterm" ]; then
   PS1='\h \w-> \[\033]0;\h \w\007\]'
else
   PS1='\h \w-> '
fi
</pre>
PS1 is an environment variable used in bash and ksh for storing the
normal prompt.  \h and \w are shorthand for hostname and working
directory in bash.  The \[ and \] strings enclose non-printing
characters from the prompt so that command line editing will work
correctly.  The \O33]0; and \007 strings enclose a string which
xterm will use for the title bar and icon name.  Sorry, I don't
remember the codes for setting these independently.  (ksh users note:
\033 is octal for ESC and \007 is octal for CTRL-G.)  This example just
changes the title bar and icon names to match the prompt before the
cursor.
<p>
Any program which changes the xterm title will cause inconsistencies if
you try an alias for cd instead of PS1.  Consider rlogin to another
machine which changes the xterm title.  When you quit rlogin, there is
nothing to force the xterm title back to the correct value when using
the cd alias (at least not until the next cd).  This is not a problem
when using PS1.
<p>
You could still alias vi to change the xterm title bar, but it may not
always be correct.  If you use ":e filename" to edit a new file, vi
will not update the xterm title.  I would suggest upgrading to vim (VI
iMproved).  It has many nice new features in addition to displaying the
current filename on the xterm title.
<p>
Hopefully this tip is a good starting point for some more experimenting.
Good luck!
<p>
Lee Bradshaw, bradshaw@nlc.com

<P> <hr> <P> 
<!--================================================================-->
<A HREF="./lg_toc13.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_mail13.html"><IMG SRC="../gx/back2.gif" ALT=" Back "></A>
<A HREF="lg_bytes13.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>