File: lg_tips20.html

package info (click to toggle)
lg-issue20 5-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,472 kB
  • ctags: 146
  • sloc: makefile: 34; sh: 34
file content (1417 lines) | stat: -rw-r--r-- 46,982 bytes parent folder | download
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
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> 
<html>
<head>
<title>More 2 Cent Tips & Tricks Issue 20</title>
</head>

<BODY BGCOLOR="#EEE1CC" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
ALINK="#FF0000">
<!--endcut ============================================================-->
<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_tips20.html#info">Boot Information Display</a>
<li><a HREF="./lg_tips20.html#glimp">Consider Glimpse Instead of Grep</a>
<li><a HREF="./lg_tips20.html#copy">Diald Remote Control</a>
<li><a HREF="./lg_tips20.html#tool">A New Tool for Linux</a>
<li><a HREF="./lg_tips20.html#hex">Hex Dump</a>
<li><a HREF="./lg_tips20.html#disk">Hard Disk Duplication</a>
<li><a HREF="./lg_tips20.html#tree">More on Grepping Files in a Directory
Tree</a>
<li><a HREF="./lg_tips20.html#disk2">More on Hard Disk Duplication</a>
<li><a HREF="./lg_tips20.html#script">A Script to Update McAfee Virus</a>
<li><a HREF="./lg_tips20.html#log">Handling Log Files</a>
<li><a HREF="./lg_tips20.html#hint">Exciting New Hint on xterm Titles</a>
<li><a HREF="./lg_tips20.html#line">C Source with Line Numbers</a>
<li><a HREF="./lg_tips20.html#package">Another Reply to "What Packages Do I
Need?"</a>
<li><a HREF="./lg_tips20.html#exec">Grepping Files in a Tree with -exec</a>
<li><a HREF="./lg_tips20.html#virtual">How Do You Un-Virtual a Virtual
Screen?</a>
<li><a HREF="./lg_tips20.html#size">File Size Again...</a>
<li><a HREF="./lg_tips20.html#syslog">Syslog Thing</a>
<li><a HREF="./lg_tips20.html#ascii">Ascii Problems with FTP</a>
<li><a HREF="./lg_tips20.html#squake">Running Squake from Inside X</a>
<li><a HREF="./lg_tips20.html#copying">Copying a Tree of Files</a>
<li><a HREF="./lg_tips20.html#shar">Using shar + RCS to Backup Sets of
Source Files</a>
<li><a HREF="./lg_tips20.html#learning">Learning Experiences</a>
<li><a HREF="./lg_tips20.html#comments">LG #19, Grepping Files Comments</a>
</ul>

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

<a name="info"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Boot Information Display
</H3>
<P> 
Date: Wed, 2 Jul 1997 18:18:11 -0400<br>
From: Jon Cox <a href="mailto:jcox@cs.tufts.edu">jcox@cx.tufts.edu</a>
<P>
I saw an article in July's LG that talked about using watch as a better
way to monitor ftp downloads -- there 's an even BETTER way:

Check out ncftp.  It works much like ftp, but shows a progress bar,
estimates time to completion, and saves bookmarks of where you've been.
I think ncftp is pretty standard on all distributions these days.

  <p>                   -Enjoy
                     Jon
<P> <hr> <P> 
<!--================================================================-->

<a name="glimp"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Consider Glimpse Instead of Grep
</H3>
<P> 
Date: Wed, 2 Jul 1997 18:18:11 -0400<br>
From: Jon Cox <a href="mailto:jcox@cs.tufts.edu">jcox@cx.tufts.edu</a>
<P>

While grep works as a tool for searching through a big directory tree
for a string, it's pretty slow for this kind of thing & a much better
tool exists --<B>Glimpse</B>.   It even has an agrep-style stripped down
regexp capability for doing &quot;fuzzy search&quot;, and is astonishingly fast.
Roughly speaking:<br>

<I>glimpse  is to  grep   as<br>
locate   is to  find</I>

<p>I believe the latest rpm version is   glimpse-4.0-4.i386.rpm
You can find it in any site that mirrors Red hat's contrib directory.

<p>                       Enjoy!<br>                       
                        -Jon


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

<a name="copy"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Diald Remote Control
</H3>
<P> 
Date: Wed, 2 Jul 1997 18:18:11 -0400<br>
From: Wim Jongman <a
href="mailto:dblyuiam@xs4all.nl">dblyuiam@xs4all.nl</a>
<P>


I have hacked a helpful utility. Please have a look at it.

<p>Regards,<br>
Wim Jongman

<HR>
<H2>
 Diald Remote Control</H2>

<HR>

<P>I have been a satisfied diald user for&nbsp; quite some time. one of
the things that were on my list of favorites was the possibility to activate
the link from another location.&nbsp; I have written a small shell script
that waits for activity on my telephone line.

<P>If activity&nbsp; has been detected the script submits the ping utility
which&nbsp; causes diald to set up a link to my ISP.&nbsp; If activity
is detected from the inside (diald does the dialing) then the ping is also
performed but there can be no harm in that.

<P>My /etc/diald.conf looks like this:

<P><TT>mode cslip</TT>
<BR><TT>connect /usr/local/bin/connect</TT>
<BR><TT>device <I><FONT COLOR="#CC66CC">/dev/cua2</FONT></I></TT>
<BR><TT>speed 115200</TT>
<BR><TT>modem</TT>
<BR><TT>lock</TT>
<BR><TT>crtscts</TT>
<BR><I><TT><FONT COLOR="#CC66CC">local local.ip.ad.dres</FONT></TT></I>
<BR><I><TT><FONT COLOR="#CC66CC">remote ga.te.way.address</FONT></TT></I>
<BR><TT>mtu 576</TT>
<BR><TT>defaultroute</TT>
<BR><I><TT><FONT COLOR="#CC66CC">ip-up /usr/local/bin/getmail &amp;</FONT></TT></I>
<BR><TT><FONT COLOR="#FF0000">ip-down /usr/local/bin/waitmodem &amp;</FONT></TT>
<BR><TT>include /usr/lib/diald/standard.filter</TT>

<P>The first time the link goes down, the program waitmodem is submitted.
The script for /usr/local/bin/waitmodem is:

<P><TT>#!/bin/bash</TT><TT></TT>

<P><TT># This script waits for data entering the modem. If data has arrived,</TT>
<BR><TT># then a host is pinged to allow diald to</TT>
<BR><TT># setup a connection (and you to telnet in.)</TT><TT></TT>

<P><TT>if test -f /var/locks/waitmodem</TT>
<BR><TT>&nbsp;then</TT>
<BR><TT>&nbsp;exit 0</TT>
<BR><TT>&nbsp;&nbsp; else</TT>
<BR><TT>&nbsp;touch /var/locks/waitmodem</TT>
<BR><TT>&nbsp;sleep 5</TT>
<BR><TT>&nbsp;read myvar &lt; <I><FONT COLOR="#CC66CC">/dev/cua2</FONT></I></TT>
<BR><TT>&nbsp;ping -c 10 <I><FONT COLOR="#CC66CC">host.com</FONT></I> >
/dev/nul &amp; > /dev/nul</TT>
<BR><TT>&nbsp;rm /var/locks/waitmodem</TT>
<BR><TT>&nbsp;exit 0</TT>
<BR><TT>fi</TT>

<P>If the diald decides to drop the link, the ip-down keyword activates
the waitmodem script. This creates a lock in /var/lock(s) and sleeps for
five seconds to allow the modem buffers to flush. Then the modem device
is read and if activity occurs, the ping is submitted. Change the <I>italic</I>
bits in the scripts. The lock is removed and diald dials out. This allows
you to access your machine. I guess you have to have a static ip for it
to be useful.

<P>Regards,

<P>Wim Jongman

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

<a name="tool"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
A New Tool for Linux
</H3>
<P> 
Date: Wed, 2 Jul 1997 18:18:11 -0400<br>
From: Jordi Sanfeliu <a
href="mailto:mikaku@arrikis.es">mikaku@arrakis.es</a>
<P>

hi !<br>

<p>This is my contribution to this beautiful gazette !! :))

<P><B>tree</B> is a simple tool that allows you to see the whole directory tree on
your hard disk.

<p>I think that is very cool, no?
<pre>
#!/bin/sh
#         @(#) tree      1.1  30/11/95       by Jordi Sanfeliu
#                                         email: mikaku@arrakis.es
#
#         Initial version:  1.0  30/11/95
#         Next version   :  1.1  24/02/97   Now, with symbolic links
#
#         Tree is a tool for view the directory tree (obvious :-) )
#
search () {
   for dir in `echo *`
   do
      if [ -d $dir ] ; then
         zz=0
         while [ $zz != $deep ]
         do
            echo -n &quot;|   &quot;
            zz=`expr $zz + 1`
         done
         if [ -L $dir ] ; then
            echo &quot;+---$dir&quot; `ls -l $dir | sed 's/^.*'$dir' //'`
         else
            echo &quot;+---$dir&quot;
            cd $dir
            deep=`expr $deep + 1`
            search    # with recursivity ;-)
            numdirs=`expr $numdirs + 1`
         fi
      fi
   done
   cd ..
   if [ $deep ] ; then
      swfi=1
   fi
   deep=`expr $deep - 1`
}

# - Main -
if [ $# = 0 ] ; then
   cd `pwd`
else
   cd $1
fi
echo &quot;Initial directory = `pwd`&quot;
swfi=0
deep=0
numdirs=0
zz=0

while [ $swfi != 1 ]
do
   search
done
echo &quot;Total directories = $numdirs&quot;
</pre>

<p>Have fun !<br>

Jordi


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

<a name="hex"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Hex Dump
</H3>
<P> 
Date: Wed, 18 Jun 1997 10:15:26 -0700<br>
From: James Gilb <a href="mailto:p27451@am371.geg.mot.com">p27451@am371.geg.mot.com</a>
<P>

I liked your gawk solution to displaying hex data.  Two things (which
people have probably already pointed out to you).
<ol>

<li>If you don't want similar lines to be replaced by *  *, use the -v
option to hexdump.  From the man page:

<p><b>-v</b>: The -v option causes hexdump to display all input data.
Without the -v option, any number of groups of output lines,
which would be identical to the immediately preceding group
of output lines (except for the input offsets), are replaced
with a line comprised of a single asterisk.

<li>In emacs, you can get a similar display using ESC-x hexl-mode.  The
output looks something like this:

<pre>00000000: 01df 0007 30c3 8680 0000 334e 0000 00ff  ....0.....3N....
00000010: 0048 1002 010b 0001 0000 1a90 0000 07e4  .H..............
00000020: 0000 2724 0000 0758 0000 0200 0000 0000  ..'$...X........
00000030: 0000 0760 0004 0002 0004 0004 0007 0005  ...`............
00000040: 0003 0003 314c 0000 0000 0000 0000 0000  ....1L..........
00000050: 0000 0000 0000 0000 0000 0000 2e70 6164  .............pad
00000060: 0000 0000 0000 0000 0000 0000 0000 0014  ................
00000070: 0000 01ec 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0008 2e74 6578 7400 0000 0000 0200  .....text.......
00000090: 0000 0200 0000 1a90 0000 0200 0000 2a98  ..............*.</pre>

<p>(I don't suppose it is surprising that emacs does this, after all, emacs
is not just and editor, it is its own operating system.)
</ol>
<P> <hr> <P> 
<!--================================================================-->

<a name="disk"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Hard Disk Duplication
</H3>
<P> 
Date: Tue, 24 Jun 1997 11:54:48 +0200<br>
From: Jerko Golubovic <a href="mailto:jerko.golubovic@public.srce.hr">jerko.golubovic@public.srce.hr</a>
<P>

<p>A comment on article &quot;HARD DISK DUPLICATION&quot; written by
mcablec@ucsd.edu in Linux Gazette #18 (June 97).

<p>What I did at my place is following:

<p>I SetUp root-NFS system to boot usable configuration over network. I
just need a floppy with appropriate kernel command-line and system
brings up.

<p>When system brings up I mount as /root NFS volume where I store
compressed images. In that way I have them readily available when I
log-in.

<p>With dmesg I find about geometry of the hard disk of the target system.
Then, for taking a new image I do:

<pre>cat /dev/hda | gzip -9 &gt; &lt;somename&gt;.gz</pre>

<p>And for restore:

<pre>zcat &lt;somename&gt;.gz &gt; /dev/hda</pre>

<p>Of course, I don't have to use such system. It is enough to prepare one
boot floppy containing just FTP client and network config. I made two
shell scripts:
<pre>
b:
----------------------
#!/bin/sh
cat /dev/hda | gzip -9

r:
----------------------
#!/bin/sh
gzip -d > /dev/hda

Then, in FTP you do:

put |./b &lt;somename&gt;.gz            - to save image
get &lt;somename.gz&gt; |./r             - to restore image
</pre>

<p>ANY FTP server on ANY platform can be used for storage.

<p>Not only that - you don't have to use FTP at all - you can use smbclient
instead - and read directly from Win or Lanman shares - doing basically
the same thing.


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

<a name="tree"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
More on Grepping Files in a Directory Tree
</H3>
<P> 
Date:Tue, 1 Jul 1997 13:12:34<br>
From: Gene Gotimer <a href="mailto:gotimer@cybercash.com">gotimer@cybercash.com</a>
<P>

In Linux Gazette Issue 18, Earl Mitchell (earlm@Terayon.COM) suggested

  <pre> grep foo `find . -name \*.c -print`</pre>

<p>as a way to grep files in a directory tree. He warned about a command
line character limit (potentially 1024 characters). 

<p>Another way to accomplish this, without the character limit, is to use
the xargs command:

  <pre>find . -name '*.c' -print | xargs grep foo</pre>

<p>The xargs command accepts arguments on standard input, and tacks them
on the end of the specified command (after any supplied parameters). 

<p>You can specify where in the command xargs will place the arguments
(rather than just on the end) if you use the -i option and a pair of
curly braces wherever you want the substitution:

  <pre>ls srcdir | xargs -i cp srcdir/{} destdir/{}</pre>

<p>xargs has a number of options worth looking at, including -p to
confirm each command as it is executed. See the man page.
<p>
--
Gene Gotimer


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

<a name="disk2"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
More on Hard Disk Duplication
</H3>
<P> 
Date: Mon, 23 Jun 1997 08:45:48 +0200<br>
From: Jean-Philippe CIVADE <a href="mailto:jpcivade@cge-ol.fr">jpcivade@cge-ol.fr</a><br>
<P>

I've written an utility under Windows 95 able to copy from disk to disk
in a biney way. It's called Disk2file. It's findable on my web site under
tools. The primary purpose of this utility was to make iso images from
a hard disk (proprietary file system) to record them on a cdrom. I've
used it yesterday do duplicate a red hat 4.1 installed disk with success.
The advantage of this method is this is possible to product a serial of
disk very quickly. This utility is written to tranfert up to 10Mb /s.
The duplication time for a 540 Mb is about 10 mins.

<p>The way to use it is:
<ol>
<li>start the program. Select scsi controller.
<li>Select a disk and a file where to put image file
<li>Select the source disk
<li>select disk2file mode and click &quot;run&quot;
<li>after completion, select the new disk where the image have to be
written
<li>Select file2disk mode
<li>Click run
</ol>
<p>It's referenced as a shareware in the docs but I conced the freeware
mode to the Linux community for disk duplication only.
<p>
-- 
Best Regards
Jean-Philippe CIVADE

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

<a name="script"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
A Script to Update McAfee Virus
</H3>
<P> 
Date: Fri, 20 Jun 1997 00:05:33 -0500 (CDT)<br>
From: Ralph <a href="mailto:ralphs@kyrandia.com">ralphs@kyrandia.com</a><br>
<P>

Here is a script I hacked together (trust me after you see it I'm sure
you'll understand why this is my first script hack I'm sure) to ftp McAfee
virus definitions unzip then and run a test to make sure they are ok...now
ya gotta have vscan for linux located at

<a href="ftp://ftp.mcafee.com/pub/antivirus/unix/linux">ftp://ftp.mcafee.com/pub/antivirus/unix/linux</a>

<p>the first one does the work of pulling it down unzipping and testing

<pre>
#!/bin/sh
# =====================================================================
# Name:         update-vscan
# Goal:         Auto-update McAfee's Virus Scan for Linux
# Who:          Ralph Sevy ralphs@kyrandia.com
# Date:         June 19 1997
# ----------------------------------------------------------------------
# Run this file on the 15th of each month to insure that the file gets
# downloaded
# ======================================================================
datafile=dat-`date +%y%m`.zip
mcafeed=/usr/local/lib/mcafee
ftp -n ftp.mcafee.com << !
user anonymous root@home.com
binary
cd /pub/antivirus/datfiles/2.x
get $datafile
quit
!
if [ -f $mcafeed/*.dat ]; then
        rm *.dat
fi
unzip $datafile *.DAT -d $mcafeed
for file in $(ls $mcafeed/*.DAT); do
        lconvert $mcafeed/*.DAT
done
uvscan $mcafeed/*
exit
---------------------------------------------------------------------------
CUT HERE

lconvert is a 3 line script I stole looking in the gazette

CUT HERE
--------------------------------------------------------------------------
#!/bin/tcsh
# script named lconvert
foreach i (*)
mv $1 `echo $1 | tr '[A-Z]' '[a-z]'`
-------------------------------------------------------------------------
CUT HERE
</pre>

<p>The last thing you want to do is add an entry to crontab to update your
files once a month....I prefer the 15th as it makes sure I get the file
(dunno really how to check for errors yet, its my next project)
<pre>
# crontab command line
# update mcafee data files once a month on the 15th at 4am
* 4 15 * * /usr/local/bin/update-vscan
</pre>

<p>Its not pretty I'm sure, but it works

<p>
Ralph
<a href="http://www.kyrandia.com/~ralphs">http://www.kyrandia.com/~ralphs</a>


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

<a name="log"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Handling Log Files
</H3>
<P> 
Date: Thu, 3 Jul 1997 11:13:56 -0400<br>
From: Neil Schemenauer <a href="mailto:nas170@mail.usask.ca">nas170@mail.usask.ca</a>
<P>

I have seen a few people wondering what to do with log files that keep
growing.  The easy solution is to trim them using:

<pre>cat &lt;/dev/null &gt;some_filename</pre>

The disadvantage to this method is that all your logged data is gone,
not just the old stuff.  Here is a shell script I use to prevent this
problem.
<pre>
#!/bin/sh
#
# usage: logroll [ -d &lt;save directory&gt; ] [ -s &lt;size&gt; ] &lt;logfile&gt;


# where to save old log files
SAVE_DIR=/var/log/roll

# how large should we allow files to grow before rolling them
SIZE=256k

while :
do
	case $1 in
	-d)
		SAVE_DIR=$2
		shift; shift;;
		
	-s)
		SIZE=$2
		shift;shift;;
	-h|-?)
		echo  &quot;usage: logroll [ -d &lt;save directory&gt; ] [ -s &lt;size&gt; ] &lt;logfile&gt;&quot;
		exit;;

	*)
		break;;
	esac
done

if [ $# -ne 1 ]
then
	echo  &quot;usage: logroll [ -d &lt;save directory&gt; ] [ -s &lt;size&gt; ] &lt;logfile&gt;&quot;
	exit 1
fi


if [ -z `find $1 -size +$SIZE -print` ]
then
	exit 0
fi

file=`basename $1`
if [ -f $SAVE_DIR/$file.gz ]
then
	/bin/mv $SAVE_DIR/$file.gz $SAVE_DIR/$file.old.gz
fi

/bin/mv $1 $SAVE_DIR/$file
/bin/gzip -f $SAVE_DIR/$file
# this last command assumes the PID of syslogd is stored like RedHat
# if this is not the case, &quot;killall -HUP syslogd&quot; should work
/bin/kill -HUP `cat /var/run/syslog.pid`
</pre>

Save this script as /root/bin/logroll and add the following to your
/etc/crontab:
<pre>
# roll log files
30 02 * * * root /root/bin/logroll /var/log/log.smb
31 02 * * * root /root/bin/logroll /var/log/log.nmb
32 02 * * * root /root/bin/logroll /var/log/maillog
33 02 * * * root /root/bin/logroll /var/log/messages
34 02 * * * root /root/bin/logroll /var/log/secure
35 02 * * * root /root/bin/logroll /var/log/spooler
36 02 * * * root /root/bin/logroll /var/log/cron
38 02 * * * root /root/bin/logroll /var/log/kernel
</pre> 
Now forget about log files.  The old log file is stored in
/var/log/roll and gzipped to conserve space.  You should have lots of
old logging information if you have to track down a problem.

<p>Neil


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

<a name="hint"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Exciting New Hint on xterm Titles
</H3>
<P> 
Date: Fri, 27 Jun 1997 15:43:44 +1000 (EST)<br>
From: Damian Haslam <a href="mailto:damian@srsuna.shlrc.mq.edu.au">damian@srsuna.shlrc.mq.edu.au</a><br>
<P>

Hi, after searching (to no avail) for a way to display the currently
executing process in the xterm on the xterm's title bar, I resorted to
changing the source of bash2.0 to do what I wanted. 

from line 117 of eval.c in the source, add the lines marked with <tt>#</tt> (but
don't include the <tt>#</tt>)
<pre>
 117: if (read_command () == 0) 
 118:        { 
#119:          if (strcmp(get_string_value(&quot;TERM&quot;),&quot;xterm&quot;) == 0) { 
#120:            printf(&quot;^[]0;%s^G&quot;,make_command_string(global_command)); 
#121:            fflush(stdout); 
#122:          } 
#123: 
 124:          if (interactive_shell == 0 && read_but_dont_execute) 
.....
</pre>
you can then set PROMPT_COMMAND to reset the xterm title to the pwd, or
whatever takes your fancy.

<p>cheers - damian

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

<a name="dmesg"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
C Source with Line Numbers
</H3>
<P> 
Date: Sun, 29 Jun 1997 10:09:52 -0400 (EDT)<br>
From: Tim Newsome <a href="mailto:drz@froody.bloke.com">drz@froody.bloke.com</a>
<P>


Another way of getting a file numbered:
<pre>grep -n $ &lt;filename&gt;</pre>
<pre>-n</pre> tells grep to number its output, and $ means end-of-line. Since every line
in the file has an end (except possibly the last one) it'll stick a number in
front of every line.
<p>
Tim

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

<a name="package"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Another Reply to &quot;What Packages Do I Need?&quot;
</H3>
<P> 
Date: Wed, 02 Jul 1997 20:17:26 +0900<br>
From: Matt Gushee <a href="mailto:matt@it.osha.sut.ac.jp">matt@it.osha.sut.ac.jp</a>
<P>

About getting rid of X components, Michael Hammel wrote that &quot;...you
still need to hang onto the X applications (/usr/X11R6/bin/*).&quot; We-e-ll,
I think that statement needs to be qualified. Although I'm in no sense
an X-pert, I've poked around and found quite a few non-essential
components: multiple versions of xclocks (wristwatches are more accurate
and give your eyes a quick break). Xedit (just use a text-mode editor in
an xterm). Fonts? I could be wrong, but I don't see any reason to have
both 75 and 100dpi fonts; and some distributions include Chinese &
Japanese fonts, which are BIG, and which not everyone needs. Anyway,
poking around for bits and pieces you can delete may not be the best use
of your time, but the point is that X seems to be packaged with a very
broad brush. By the way, I run Red Hat, but I just installed the new
(non-rpm) XFree86 3.3 distribution--and I notice that Red Hat packages
many of the non-essential client programs in a separate contrib
package, while the Xfree86 group puts them all in the main bin/ package.

<p>Here's another, maybe better idea for freeing up disk space: do you have
a.out shared libraries? If you run only recent software, you may not
need them. I got rid of my a.out libs several months ago, and have
installed dozens of programs since then, and only one needed a.out (and
that one turned out not to have the features I needed anyway). Of
course, I have the RedHat CD handy so I can reinstall them in a moment
if I ever really need them.

<p>That's my .02 .<br>
--Matt Gushee

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

<a name="exec"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Grepping Files in a Tree with -exec
</H3>
<P> 
Date: Wed, 2 Jul 1997 09:46:33 -0400 (EDT)<br>
From: Clayton L. Hynfield <a href="mailto:hynfiecl@mnemo.mcs.muohio.edu">hynfiecl@mnemo.mcs.muohio.edu</a><br>
<P>


Don't forget about find's -exec option:

<pre>find . -type f -exec grep foo {} \;</pre>

<p>Clayton L. Hynfield  



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

<a name="virtual"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
How Do You Un-Virtual a Virtual Screen?
</H3>
<P> 
Date: Mon, 07 Jul 97 15:08:39 +1000<br>
From: Stuart Lamble <a href="mailto:lamble@yoyo.cc.monash.edu.au">lamble@yoyo.cc.monash.edu.au</a><br>
<P>

With regards to changing the size of the X screen, I assume you're using
XFree86. XFree will make your virtual screen size the larger of:

*the specified virtual screen size
*the _largest_ resolution you _might_ use with your video card
    (specified in 'Section &quot;Screen&quot;').

<p>Open your XF86Config file in any text editor (ae, vi, emacs, jed, joe, ...)
_as root_. (You need to be able to write it back out again.) Search for
&quot;Screen&quot; (this is, IIRC, case insensitive, so for example, under vi, you'd
type:

<pre>/[Ss][Cc][Rr][Ee][Ee][Nn]</pre>

yeah, yeah, I know there's some switch somewhere that makes the search
case insensitive (or if there isn't, there _should_ be :), but I can't
remember it offhand; I don't have much use for such a thing.)

<p>You'll see something like:
<pre>
Section &quot;Screen&quot;
    Driver      &quot;accel&quot;
    Device      &quot;S3 Trio64V+ (generic)&quot;
    Monitor     &quot;My Monitor&quot;
    Subsection &quot;Display&quot;
        Depth       8
        Modes       &quot;1024x768&quot; &quot;800x600&quot; &quot;640x480&quot;
        ViewPort    0 0
        Virtual     1024 768
    EndSubsection
    Subsection &quot;Display&quot;
        Depth       16
        Modes       &quot;800x600&quot; &quot;640x480&quot;
        ViewPort    0 0
        Virtual     800 600
    EndSubsection
    Subsection &quot;Display&quot;
        Depth       24
        Modes       &quot;640x480&quot;
        ViewPort    0 0
        Virtual     640 480
    EndSubsection
EndSection
</pre>
(this is taken from a machine I use on occasion at work.)

<p>The first thing to check is the lines starting with Virtual. If you want
the virtual resolution to be the same as the screen size, it's easy to do -
just get rid of the Virtual line, and it'll be set to the highest
resolution listed in the relevant Modes line. (In this case, for 24bpp,
it would be 640x480; at 16bpp, 800x600; at 8bpp, 1024x768.) Just be
aware that if you've got a 1600x1200 mode at the relevant depth listed,
the virtual screen size will stay at 1600x1200. You'd need to get rid of
the higher resolution modes in this case.

<p>I would strongly recommend you make a backup of your XF86Config file
before you mess around with it, though. It's working at the moment;
you want to keep it that way :-)

<p>All of this is, of course, completely incorrect for MetroX, or any other
commercial X server for Linux.

<p>Cheers.


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

<a name="size"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
File Size Again...
</H3>
<P> 
Date: Sun, 6 Jul 1997 13:13:29 -0400 (EDT)<br>
From: Tim Newsome <a href="mailto:drz@froody.bloke.com">drz@froody.bloke.com</a>
<P>

<p>Since nobody has mentioned it yet: procps (at least version 1.01) comes with a
very useful utility named watch. You can give it a command line which it will
execute every 2 seconds. So, to keep track of file size, all you really need
is:
watch ls -l filename
Or if you're curious as to who's logged on:
watch w
You can change the interval with the -n flag, so to pop up a different fortune
every 20 seconds, run:
watch -n 20 fortune

Tim


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

<a name="syslog"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
syslog Thing
</H3>
<P> 
Date: Fri, 04 Jul 1997 14:50:08 -0400<br>
From: Ian Quick <a href="mailto:ian@dot.superaje.com">ian@dot.superaje.com</a>
<P>
I don't know if this is very popular but my friend once told me a way
to put your syslog messages on a virtual console.  First make sure that
you have the dev for what console you want. (I run RedHat 4.0 and they
have them up tty12).  Then edit your syslog.conf file and add *.* &lt;put a
few tabs for format&gt; /dev/tty12.  Reboot and TA DA! just hit alt-F12 and
there are you messages logged to a console.

<p>-Ian Quick


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

<a name="ascii"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Ascii Problems with FTP
</H3>
<P> 
Date: Mon, 7 Jul 1997 15:59:39 -0600 (CST)<br>
From: Terrence Martin <a href="mailto:twm139@missing.link.ca">twm139@missing.link.ca</a>
<P>
This is a common problem that occurs with many of our Windows users when
they upload html and perl cgi stuff to our web server.

<p>The real fix for this has been available for years in ftp clients
themselves. Every ftp client should have support for both 'Binary or type
I' and 'Ascii or type 2' uploads/downloads. By selecting or toggling this
option to Ascii mode (say in ws_ftp) the dos format text files are
automagically translated to unix style without the ^M. Note you definitely
do not want to transfer binary type files like apps or programs as this
translation will corrupt them.

<p>Regards<br>
Terrence Martin


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

<a name="squake"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Running Squake from Inside X
</H3>
<P> 
Date: Fri, 11 Jul 1997 00:27:49 -0400<br>
From: Joey Hess <a href="mailto:joey@kite.ml.org">joey@kite.ml.org</a>
<P>


I use X 99% of the time, and I was getting tired of the routine of
CTRL-ALT-F1; log in; run squake; exit; switch back to X that I had to
go through every time I wanted to run squake. So I decided to add an
entry for squake to my fvwm menus. To make that work, I had to write a
script, I hope someone else finds this useful, I call it <B>runvc</B>:
<pre>
	#!/bin/sh
	# Run something on a VC, from X, and switch back to X when done.
	# GPL Joey Hess, Thu, 10 Jul 1997 23:27:08 -0400
	exec open -s -- sh -c &quot;$* ; chvt `getvc`&quot;
</pre>
Now, I can just type <tt>runvc squake</tt> (or pick my fvwm menu entry that
does the same) and instantly be playing squake, and as soon as I quit
squake, I'm dumped back into X. Of course, it works equally well for
any other program you need to run at the console.

<p>Runvc is a one-liner, but it took me some time to get it working
right, so here's an explanation of what's going on. First, the
<tt>open -s</tt> command is used to switch to another virtual console (VC)
and run a program. By default, it's going to switch to the next unused
VC, which is probably VC 8 or 9. The -s has to be there to make open
actually change to that console.

<p>Next, the text after the <tt>--</tt> is the command that open runs. I want
open to run 2 commands, so I have to make a small shell script, and
this is the <tt>sh -c &quot;...&quot;</tt> part. Inside the quotes, I place $*, which
actually handles running squake or whatever program you told runvc to
run.

<p>Finally, we've run the command and nothing remains but to switch back
to X. This is the hard part. If you're not in X, you can use something
like <tt>open -w -s -- squake</tt> and open will run squake on a new VC, wait
for it to exit, and then automatically switch back to the VC you ran
it from. But if you try this from inside X, it just doesn't work. So I
had to come up with another method to switch back to X. I found that
the <tt>chvt</tt> command was able to switch back from the console to X, so I
used it.

<p>Chvt requires that you pass it the number of the VC to switch to. I
could just hard code in the number of the VC that X runs on on my
system, and do <tt>chvt 7</tt>, but this isn't portable, and I'd have to
update the script if this ever changed. So I wrote a program named
'getvc' that prints out the current VC. Getvc is actually run first,
before any of the rest of the runvc command line, because it's
enclosed in backticks. So getvc prints out the number of the VC that X
is running on and that value is stored, then the rest of the runvc
command line gets run, and eventually that value is passed to chvt,
which finally switches you back into X.

<p>Well, that's all there is to runvc. Here's where you can get the
programs used by it:
<ul>
<li><b>open</b>: In the open package, from
<a href="ftp://sunsite.unc.edu/pub/Linux/utils/console/open-1.4.tgz">ftp://sunsite.unc.edu/pub/Linux/utils/console/open-1.4.tgz</a>
<li><b>chvt</b>: Part of the kbd package, from
<a href="ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linus/kbd-0.94.tar.gz">ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linux/kdb-0.94.tar.gz</a>
<li><b>getvc</b>: I wrote this one, here's the source code, it's easy to
        compile. I won't go into how it works, because I don't
        understand it well - I just stole code from somewhere else and
        hacked it to do what I wanted.
<pre>
	/* getvc.c
	 * Prints the number of the current VC to stdout. Most of this code
	 * was ripped from the open program, and this code is GPL'd
	 *
	 * Joey Hess, Fri Apr  4 14:58:50 EST 1997
	 */
	
	#include &lt;sys/vt.h&gt;
	#include &lt;fcntl.h&gt;
	
	main () {
	  int fd = 0;
	  struct vt_stat vt;
	
	  if ((fd = open(&quot;/dev/console&quot;,O_WRONLY,0)) < 0) {
	    perror(&quot;Failed to open /dev/console\n&quot;);
		    return(2);
	  }
	  if (ioctl(fd, VT_GETSTATE, &vt) < 0) {
	    perror(&quot;can't get VTstate\n&quot;);
	    close(fd);
	    return(4);
	  }
	  printf(&quot;%d\n&quot;,vt.v_active);
	}
	
	/* End of getvc.c */</pre>
		
<p>I hope this tip isn't too long!
<p>
-- 
see shy jo

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

<a name="copying"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Copying a Tree of Files
</H3>
<P> 
Date: Fri, 18 Jul 1997 00:33:48 +0200 (SAT)<br>
From: <a href="mailto:ixion@ilink.nis.za">ixion@ilink.nis.za</a>
<P>


Hi!

<p>First of all, I want to congratulate you with your fine magazine.
Although I've been around for quite some time and known about the
existance of LG, I've never had the time (or should I say I have been
to ignorant) to read it. Well, I finally sat down and started reading
all the issues and I must say I'm impressed. Therefore I decided I
would show my gratitude by showing you some of my 2c Tips. Enjoy...
<pre>
# Quick way to copy a tree of files from one place to another
----&lt; cptree &lt;----
#!/bin/sh
if [ $# = 2 ]
then
    (cd $1; tar cf - .) | (mkdir $2; cd $2; tar xvfp -)
else
    echo &quot;USAGE: &quot;`basename $0`&quot; &lt;source_directory&gt; &lt;dest_directory&gt;&quot;
    exit 1
fi
----&lt; cptree &lt;----

# Quick way to move a tree of files from one place to another
----< mvtree <----
#!/bin/sh
if [ $# = 2 ]
then
    (cd $1; tar cf - .) | (mkdir $2; cd $2; tar xvfp -)
    rm -rf $1
else
    echo &quot;USAGE: &quot;`basename $0`&quot; &lt;source_directory&gt; &lt;dest_directory&gt;&quot;
    exit 1
fi
----&lt; mvtree &lt;----

# Rename numeric files (1.*, 2.*, 3.*, etc.) to it's correct numeric
# equivalents (01.*, 02.*, 03.*, etc.). Useful to prevent incorrect wild
# card matching
----< fixnum <----
#!/bin/sh
if [ $# = 0 ]
then
    FILELIST=`ls {1,2,3,4,5,6,7,8,9}.mp3` 2> /dev/null
    MPFILE=&quot;empty&quot;
    chmod -x *
    for MPFILE in $FILELIST
    do
      if [ -e $MPFILE ]; then mv $MPFILE &quot;`echo &quot;0$MPFILE&quot;`&quot;; fi
    done
fi
----< fixnum <----

# This one strips the given file name from it's extension (i.e. &quot;file.txt&quot;
# would become &quot;file&quot;
----< cutbase <----
#!/bin/sh
if [ $# = 1 ]
then
    dotpos=`expr index $1 &quot;.&quot;`
    if [ $dotpos -gt 0 ]
    then
        dotpos=`expr $dotpos - 1`
        stripfile=`expr substr $1 1 $dotpos`
    else
        stripfile=$1
    fi
    echo $stripfile
else
    echo &quot; USAGE: `basename $0` &lt;filename&gt;&quot;
    exit 1
fi
----&lt; cutbase &lt;----

# If you're desperately looking for a file containing something and you
# don't have a clue where to start looking, this one might be for you.
# It greps through all the files in the given directory tree for the given
# keyword and list all the files. For example: grepall /usr/doc PAP secrets
----< grepall <----
#!/bin/sh
if [ $# = 0 ]
then
    DIR=&quot;.&quot;
else
    DIR=$1
    shift
    find $DIR -type f -exec grep -lie &quot;$@&quot; {} \; | less
fi
----< grepall <----

# You might have seen some of the xterm titlebar tips posted in LG. Here
# is my variation of the theme. I like my xterm to keep it's title that
# I've either specified on the command-line or the name of the program
# and after I've run programs like Midnight Commander, that's changes the
# titlebar, I want it restored to it's old value. Here is my way of doing
# it. Just put the code in /etc/profile or ~/.profile or whatever startup
# file you use...
----< Titlebar 2c tip <----
if [ $TERM = &quot;xterm&quot; -o $TERM = &quot;xterm-color&quot; -o $TERM = &quot;rxvt&quot; ]
then
    function TitlebarString()
    {
      local FOUND=0
      local PIDTXT=`ps | grep $PPID`
      for WORDS in $PIDTXT
      do
        if [ $FOUND = 1 ]; then break; fi
        if [ $WORDS = &quot;-T&quot; ]; then export FOUND=1; fi
      done
      if [ $FOUND = 0 ]
      then
          WORDS=`(for TMP in $PIDTXT;do echo -n $TMP&quot; &quot;;done) | cut -f5 -d&quot; &quot;`
          if [ &quot;`echo $WORDS | grep -i xterm`&quot; != &quot;&quot; ]; then WORDS=&quot;xterm&quot;; fi
      fi
      echo -n $WORDS
      unset WORDS
    }
    if [ $COLORTERM -a $COLORTERM = &quot;rxvt-xpm&quot; ]
    then
        alias mc='mc -c;echo -ne &quot;\033[m\033]0;`TitlebarString`\007&quot;'
    else
        alias mc='mc -c;echo -ne &quot;\033]0;`TitlebarString`\007&quot;'
    fi
fi
----< Titlebar 2c tip <----

# This is an add-on for du. It shows the total disk usage in bytes,
# kilobytes, megabytes and gigabytes (I thought terabytes wouldn't be
# necessary (: )
----< space <----
#!/bin/sh
BYTES=`du -bs | cut -f1` 2> /dev/null
if [ $BYTES -lt 0 ]
then
    KBYTES=`du -ks | cut -f1` 2> /dev/null
else
    KBYTES=`expr $BYTES / 1024`
fi
MBYTES=`expr $KBYTES / 1024`
GBYTES=`expr $MBYTES / 1024`
echo &quot;&quot;
if [ $BYTES -gt 0 ]; then echo &quot; $BYTES bytes&quot;; fi
if [ $KBYTES -gt 0 ]; then echo &quot; $KBYTES KB&quot;; fi
if [ $MBYTES -gt 0 ]; then echo &quot; $MBYTES MB&quot;; fi
if [ $GBYTES -gt 0 ]; then echo &quot; $GBYTES GB&quot;; fi
echo &quot;&quot; 
----< space <----

# A scripty to unzip all zipfiles specified or all those in the current
# directory and remove the orginal ones (Remember that GNU zip/unzip
# doesn't support wildcards)
----< unzipall <----
#!/bin/sh
if [ $# = 0 ]
then
    ZIPLIST=`ls *.zip` 2> /dev/null
else
    ZIPLIST=&quot;$@&quot;
fi
ZIPFILE=&quot;garbage&quot;
for ZIPFILE in $ZIPLIST
do
  unzip -L $ZIPFILE
done
rm -f $ZIPLIST 2> /dev/null
----< unzipall <----

# Zip all the files in the current directory seperately and wipe the
# original files. Zip's them in a dos style (i.e. hungry.txt would
# be zipped to hungry.zip and not hungry.txt.zip)
----< zipall <----
#!/bin/sh
function stripadd ()
{
  local dotpos=`expr index $1 &quot;.&quot;`
  if [ $dotpos -gt 0 ]
  then
      dotpos=`expr $dotpos - 1`
      local stripfile=`expr substr $1 1 $dotpos`
  else
      local stripfile=$1
  fi
  echo $stripfile&quot;.zip&quot;
}
function ziplist ()
{
  zipfile=&quot;garbage&quot;
  for zipfile in &quot;$@&quot;
  do
    zip -9 `stripadd $zipfile` $zipfile
    rm $zipfile
  done
}
if [ $# -gt 0 ]
then
    ziplist &quot;$@&quot;
else
    ziplist `ls`
fi
----< zipall <----
</pre>

<p>Okay, now for some Window manager tips. Since '95 microsoft has launched
a '95 keyboard campaign and in the process a lot of people (including me)
have ended up with keyboards containing those silly, useless buttons.
Luckily I've put them to good use. To give them the same functions in your
window manager as in doze 95, just follow the instructions:
<pre>
Edit ~/.Xmodmap and add the following lines:

keycode 115 = F30
keycode 116 = F31
keycode 117 = F32
</pre>

<p>Now, edit your window manager configuration file and bind those keys. Here
is the proper keybindings for fvwm95 and afterstep respectively
<pre>
# Fvwm95 (edit ~/.fvwm2rc95)

Key F30         A       A       CirculateDown
Key F31         A       A       CirculateUp
Key F32         A       A       PopUp &quot;Utilities&quot;

# Afterstep (edit ~/.steprc)

Key F30         A       A       CirculateDown
Key F31         A       A       CirculateUp
Key F32         A       A       PopUp &quot;HotList&quot;
</pre>

<p>Just remember that PopUp &quot;Utilities&quot; and PopUp &quot;HotList&quot; should be replaced
by your actual popup menus. If you don't known what I'm talking about, just
browse through your configuration file and read the comments - It'll become
clear very soon. 

<p>I guess that's all for now. I've got some other (more useful) scripts and
tips, but they are either system specific or just to large to include here
and if I don't stop now, you'll need a seperate issue just for my tips. 
<p>
Cheers<br>
 ixion


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

<a name="shar"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Using shar + RCS to Backup Set of Source Files
</H3>
<P> 
Date: Wed, 23 Jul 1997 09:28:24 -0300<br>
From: Mario Storti <a href="mailto:mstorti@minerva.unl.edu.ar">mstorti@minerva.unl.edu.ar</a>
<P>

Hi, RCS (see  rcs(1))  is a  very   useful tool that allows   to store
versions of a file by storing only  the differences between successive
versions.  In this way I  can make a  large amounts of backups of my
source files but with a negligible amount of storage. I use it all the
time, even for TeX files!!   However, when you are  working with a set
of source files  (*.c,  shell or  Perl   scripts, I work mainly   with
Fortran .f and Octave *.m files) what I want is to make backups of the
whole set of files in such a way that you can recover the state of the
whole package at a given time.  I know that there is a script called
<B>rcsfreeze</B> around,  but I know that  it has problems, for instance if
you  rename, delete  or  create new  files, it   is not  guaranteed to
recover the same state of the whole set.

<p>I found a solution that seems  to be simpler and  is working for me: I
make a `shar' of the   files and then   a version control of the  shar
file. (see shar(1)). Shar is a file that packs a  set of text files in
a single text file.  It has been used since a long time to send set of
files by e-mail.  

<p>It would be easy  to write a script for  this, but I prefer to include
the shell code in a Makefile.  The commands to be issued each time you
want to make a backup are:

<pre>
       $ co -l source.shar
       $ shar *.m Makefile >source.shar
       $ ci -m&quot;save package&quot; source.shar
</pre>
<p>Here *.m  and Makefile  is the  set  of  files that  I want  to backup
periodically. 

<p>(I want to point out that RCS version control is far beyond the simple
fact of  making backups:  It serves to  manage files  to be worked  by
different  people, etc... Here  I'm using  a very small  subset of the
utilities of RCS.)

<p>Hope this could be of  use for someone else.  It would be nice also to
hear of other solutions,

<p>Mario

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

<a name="learning"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
Learning Experience
</H3>
<P> 
Date: Wed, 23 Jul 1997 15:53:31 -0500<br>
From: Debie Scholz <a href="mailto:debie@sirinet.net">debie@sirinet.net</a><br>
<P>

If you have a ps2 style mouse and the /dev/psaux gets deleted you must do a
MAKEDEV busmice but it doesnt make a psaux it makes a psmouse so you must
make a symbolic link to psaux.;
<p>Debie Scholz<br>
Sirius Systems Group, Inc.<br>

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

<a name="comments"></a>
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
LG #19, Grepping Files Comments
</H3>
<P> 
Date: Wed, 30 Jul 1997 08:35:46 +0200 (MET DST)<br>
From: Werner Fleck <a href="mailto:Werner.Fleck@prompt.de">Werner.Fleck@prompt.de</a>
<P>

Hi!<br>

I have read all the 2c tips on grepping files in a directory tree but I think
all missed the ultimate tool for this: a perl script named ``mg''. With this
you can:

<ul>
<li>grep in many types of compresses archieved files e.g. tar'ed, ar'ed,
compressed, gzip'ed, zoo'ed, lha'ed...
<li>grep binary files
<li>grep only text files
<li>recursive grep in a directory tree
<li>filename pattern matching
<li>regular expresions
<li>option case insensitive match
<li>and many many more
</ul>
<p>Although it is written in perl it is very fast - I used it now for many years
and it works wonderful for me.

<p>FTP search results

<p>Hardware by Opticom ASA, ITEA and IDI. Network by UNINETT. 
This server is located in Trondheim, Norway 

<p>&quot;Exact search&quot; for &quot;mg-2.16&quot;


<pre>
  1 -r--r--r--   38.8K 1996 Oct  2 ftp.nuie.nagoya-u.ac.jp
/languages/perl/sra-scripts/mg-2.16
  2 -rw-r--r--   38.8K 1995 Nov 16 ftp.et-inf.fho-emden.de
/pub/.mnt2/perl/sra-scripts/mg-2.16
  3 -rw-r--r--   38.8K 1996 Oct  3 ftp.hipecs.hokudai.ac.jp
/pub/LANG/perl/utashiro/mg-2.16
  4 -rw-r--r--   38.8K 1997 Mar  4 ftp.st.ryukoku.ac.jp /pub/lang/perl/mg-2.16
  5 -r--r--r--   38.8K 1996 Oct  2 ftp.elelab.nsc.co.jp
/pub/lang/perl/scripts.sra/mg-2.16
  6 -r--r--r--   38.8K 1996 Oct  3 ftp.sra.co.jp       
/pub/lang/perl/scripts/utashiro-scripts/mg-2.16
  7 -r--r--r--   38.8K 1996 Oct  3 ftp.sra.co.jp       
/pub/lang/perl/sra-scripts/mg-2.16
  8 -rw-r--r--   38.8K 1995 Nov 16 ftp.fujitsu.co.jp   
/pub/misc/perl/sra-scripts/mg-2.16
  9 -r--r--r--   38.8K 1996 Oct  2 ftp.eos.hokudai.ac.jp
/pub/tools/sra-scripts/mg-2.16


9 reported hits 
0.018 seconds prospero 
0.018 seconds HTTP 
0 partial writes. 
DONE
</pre>
<p>FTP search, Copyright  1994-1997 Tor Egge 
<p>Greetings, Werner


<P> <hr> <P> 
<!--================================================================-->
<center>Published in Linux Gazette Issue 20, August 1997</center>
<P> <hr> <P> 
<!--================================================================-->
<A HREF="./index.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_mail20.html"><IMG SRC="../gx/back2.gif" ALT=" Back "></A>
<A HREF="./lg_bytes20.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> 
<!--startcut ==========================================================-->
</body> 
</html>
<!--endcut ============================================================-->