ALINK="#FF0000">

"Linux Gazette...making Linux just a little more fun! "


More 2¢ Tips!


Send Linux Tips and Tricks to gazette@linuxgazette.net


Contents:


X Limitation to 8 Bit Color

From: Gary Masters gmasters@devcg.denver.co.us

I read your question in Linux Gazette regarding an X limitation to 8 bit color when the system has more than 14 megs of RAM. Where did you find that information? I ask because my system has 24 megs of RAM, and I run 16 bit color all the time. One difference between our systems is that I am using a Diamond Stealth 64 video card.

The place I tell X to run in 16 bit mode is in the file /usr/X11R6/bin/startx. There is a line in this file that begins with serverargs. I get 16 bit mode by giving "-bpp 16" as an argument in this line (e.g. serverargs="-bpp 16").

One problem I did have was that the OpenLook Window Manager (olwm) did not like 16 bpp mode. I solved this by switching to the OpenLook Virtual Window Manager (olvwm)[1]. I also had success using the Tab and FV Window Managers (twm & fvwm) in 16 bpp mode.

Coming from a SunOS background, I'm used to OpenLook.

Gary Masters


Screen Blanking Under X

From: Gary Masters gmasters@devcg.denver.co.us

I read your question in the Linux Gazette regarding unwanted screen blanking under X after upgrading to a newer distribution of Linux. I had the same frustration. Apparently the X servers included in the Xfree86 version distributed with current Linux distributions has screen blanking compiled as a default behavior.

This behavior can be controlled with the -s option to the server. Look in the startx script for a line that begins with serverargs and add "-s 0". This will disable the X screen blank.

Gary Masters


Doubleclick Internet User Profiles

From: Kragen Javier Sittler kragen@pobox.com

Check out the description of what doubleclick.net does at http://www.doubleclick.net/frames/adinfo/dartset.htm

Then decide whether you want to be added to their database of Internet user profiles. If not, you can use the script below; I run it in my

/etc/rc.d/rc.inet1
. It prevents any DoubleClick banners from being displayed, prevents any cookies from being set, and prevents DoubleClick from collecting any data on you.

It also does the same thing with linkexchange.com, because I find their constant banners and requests for cookies annoying. If you'd prefer, you can take out the linkexchange lines.

However, this will also keep you from receiving *any* information from doubleclick or linkexchange directly... so you can't visit their web sites either.

On my machine, I put the script in

/etc/rc.d/rc.doubleclick
and run it from
/etc/rc.d/rc.inet1
at boot time, so I'm always protected from DoubleClick.
# Script begins below:

#!/bin/sh
# By Kragen Sitaker, 21 April 1997.

# Prevent any packets from reaching doubleclick.net
/sbin/route add -net 199.95.207.0 netmask 255.255.255.0 lo
/sbin/route add -net 199.95.208.0 netmask 255.255.255.0 lo

# And ad.linkexchange.com too!
/sbin/route add -net 204.71.189.0 netmask 255.255.255.0 lo


How to Mount/Unmount For Users

From: Kidong Lee kidong@shinbiro.com

When I mount/umount file, I have to login as root. It's not convenient for me & other users. but, I found the solution that user who is not root can do mount/umount in mount man page.

Take a look at /etc/fstab.

#          

/dev/hdb      /cdrom         iso9660          ro,user   0      0

Note "user" in options field. In options field, if you add "user", users can do mount/umount.


File Transfer With the z Protocol

From: Gregor Gerstmann, gerstman@tfh-berlin.de

Regarding Linux Gazette issue16, April 1997, I have some remarks regarding the article on file transfer with the z protocol: 'I type sz things go along fine, until about 40K then I get a couple of different error messages....' We have an internal modem with a transfer rate of 2880 cps on the telephone line. My son has an account at a Berlin university with a limited capacity of 5MB. We found the same error but not limited to a special file size! During the night hours, between 1 and 5h local time, when telephone costs are lowest, we sometimes transfered files up to 100KB without errors! To avoid any errors at all, I limited the packages to 20 * 1024 = 20480 bytes, if a CRC occurs, transfer begins once more but with- out timeout error, because the parcels are small. I use two proce- dures: the first, Chop, generates another procedure that chops the file to be transfered with the help of dd into packages and regu- lates the transfer and removing of transfered packages. At home we concatenate the packages again with cat ... ... > ... and everything is ok. The last step could be done by a procedure too. Of course, it is rather simple software, but it works until we will use ISDN.

first parameter - number of bytes
second		- begin of output names, e.g. p1
third		- name of file to be chopped
#!/bin/bash
echo "* Begin of procedure Chop *"
date
# rm alte Datei
if test -e /usr/TFH/EXAMPLE
	then rm /usr/TFH/EXAMPLE
fi
# Test auf Parameter
if test $# -lt 3
	then echo "Incorrect number of parameters !
Please repeat procedure call !"
echo "* End of procedure Chop (error) *"
	exit 1
	else echo "Call was ok"
fi
#
BY=$1
ANZZ=$[(($BY / 20480) + 1)]
quantity=$ANZZ
i=1
recs=0
while test "$i" -lt "$quantity"
do
echo dd if=$3 of=$2_$i bs=1024 skip=$recs count=20 >> /usr/TFH/EXAMPLE
echo sz $2_$i >> /usr/TFH/EXAMPLE
echo rm $2_$i >> /usr/TFH/EXAMPLE
	i="`expr $i + 1`"
	recs="`expr $recs + 20`"
done
echo dd if=$3 of=$2_$i bs=1024 skip=$recs >> /usr/TFH/EXAMPLE
echo sz $2_$i >> /usr/TFH/EXAMPLE
echo rm $2_$i >> /usr/TFH/EXAMPLE
#
echo "* End of procedure Chop (ok) *"
#


Using ftp Commands in Shellscript

From: Walter Harms, Walter.Harms@Informatik.Uni-Oldenburg.DE
Using FTP as a shell-command with ftplib

Working on several different networks means that you always need to copy your data from net to net. Most ppl use rcp but like most SysOps I found this to be a terrible security hole. So as I started this job my first business was to rewrite several scripts that were using rsh,rcp etc. I replaced them with an ftp based script ftp - <input> out 2> out.err. It's easy to see that this was not a good idea because ftp was not intended as shell-commando like cp,mv and the other guys. So I was happy to find the ftplib on a linux-CD. It's a nice lib that I used to build cmds like ftpmv, ftpcp, ftprm.. This made my scripts much slimmer and simpler. I have some terrible copy-scripts running but no problems copying on different systems like Ultrix or AIX.

Example using ftpget (from the ftplib Author Thomas Pfau)

ftpget sunsite.unc.edu -r /pub/Linux ls-lR.gz
This command reads the file
/pub/Linux/ls-lR.gz from sunsite.unc.edu
Likewise there are other commands with the lib: ftpdir ,ftpsend, ftprm

Who needs ftplib?
Everybody tired of typing ftp... every evening to get the latest patches or whatever. Everyone who is regularly copying with ftp the same Datafiles.

Why use ftplib?
Of course you can add it to you own application but more experienced users don't have to use these r-commands anymore. An ftpd is available for the majority of systems so it is easier to access more of them.

Any drawbacks?
Of course, for any ftp session you need a user/paswdr. I copy into public area using anonymous/email@ others will need to surly a password at login, what is not very useful for regular jobs or you have to use some kind of public login but still I think it's easier and better to use than the r-cmds.

-- walter


ACSII-Artwork Translator

Here is something interesting which you might consider for publication. It is a short program written in LEX and C, which takes ASCII-Artwork and translates it into HTML 3.0 compliant table data. It is a pretty interesting idea, and as far as I know, I'm the first person to try something like this, or automate the process. The translator (a2t) has a few options:

The program was completed just today, so it is very new. I've released it under the GNU license agreement.

For some examples of the output generated by a2t, see: http://wilkes.edu/~pkeane
I think you'll find the results to be pretty amusing, and slightly more interesting than the usual bag of HTML table-tricks.

Enjoy-- Patrick

%{

/* Ascii-to-Table version 2.0
**
** A conversion utility to convert gifscii type ASCII-Artwork into
** grayscale HTML 3.0 compliant html documents using tables.
**
** Copyright(C) 1997 by Patrick J.M. Keane --  All rights reserved.
** (pkeane@wilkes.edu)
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
*/

#include 
#include 
#include 

char shade1[4], shade2[4], shade3[4] ;
int reverse=0, widthset=0, width=0 ;
int shade1set=0, shade2set=0, shade3set=0 ;

void maketd(const char *value) {
  printf("",
	 ((shade1set==0) ? value : shade1),
	 ((shade2set==0) ? value : shade2),
	 ((shade3set==0) ? value : shade3)) ;
  printf(" ") ;
}

main(int argc, char *argv[]) {
  int c;
  extern int optind;
  extern char *optarg;
  extern int opterr;

  while ((c = getopt(argc, argv, "w:r:g:b:xh")) != EOF) {
    switch (c) {
    case 'x':
      reverse = 1 ;
      break;
    case 'h':
      fprintf(stderr, "Usage:\n\tcat asciifile | a2t [-h] [-x] [-[rgb] value] [-w width] > document.html\n\n") ;
      fprintf(stderr, "\t-h       : This help screen\n") ;
      fprintf(stderr, "\t-x       : Reverse output\n") ;
      fprintf(stderr, "\t-r value : Constant R GB value\n") ;
      fprintf(stderr, "\t-g value : Constant G RB value\n") ;
      fprintf(stderr, "\t-b value : Constant B RG<B> value\n") ;
      fprintf(stderr, "\t-w value : Set width of output table\n") ;
      exit(0) ;
      break;
    case 'r':
      shade1set = 1 ;
      strcpy(shade1, optarg) ;
      break ;
    case 'g':
      shade2set = 1 ;
      strcpy(shade2, optarg) ;
      break ;
    case 'b':
      shade3set = 1 ;
      strcpy(shade3, optarg) ;
      break ;
    case 'w':
      widthset = 1 ;
      width = atoi(optarg) ;
      break ;
    default:
      fprintf(stderr, "Bad option: %c\n", c);
      exit(1) ;
      break;
    }
  }

  printf ("Table Art!\n") ; 
  printf ("\n") ; 
  printf ("\n") ; 
  printf ("\n") ;

  printf ("
\n") ; printf ("", width) ; else printf(">") ; printf ("\n") ; yylex() ; printf("
\n") ; } %} %option yylineno ws [ ]* %% "$"|"@" { (reverse) ? maketd("00") : maketd("ff") ; } "W"|"M" { (reverse) ? maketd("20") : maketd("f7") ; } "B"|"%"|"8"|"&" { (reverse) ? maketd("20") : maketd("f0") ; } "#"|"*"|"9"|"6"|"H" { (reverse) ? maketd("20") : maketd("e7") ; } "o"|"h"|"k" { (reverse) ? maketd("27") : maketd("e0") ; } "4"|"5"|"S"|"K" { (reverse) ? maketd("30") : maketd("d7") ; } "a"|"e"|"s" { (reverse) ? maketd("37") : maketd("d0") ; } "b"|"d"|"p"|"q" { (reverse) ? maketd("40") : maketd("c7") ; } "w"|"m"|"3" { (reverse) ? maketd("47") : maketd("b7") ; } "z"|"O"|"0"|"Q" { (reverse) ? maketd("50") : maketd("b0") ; } "L"|"G"|"D"|"C"|"2" { (reverse) ? maketd("57") : maketd("a7") ; } "R"|"E"|"U"|"X" { (reverse) ? maketd("60") : maketd("a0") ; } "N"|"A"|"Y"|"P" { (reverse) ? maketd("67") : maketd("97") ; } "F"|"J"|"Z"|"z"|"c" { (reverse) ? maketd("70") : maketd("90") ; } "g"|"y" { (reverse) ? maketd("77") : maketd("85") ; } "x"|"v"|"u"|"n" { (reverse) ? maketd("80") : maketd("80") ; } "="|"I"|"r"|"j"|"T" { (reverse) ? maketd("87") : maketd("77") ; } "f"|"t" { (reverse) ? maketd("90") : maketd("70") ; } "|"|"?"|"V"|"/"|"\\"|"7" { (reverse) ? maketd("97") : maketd("67") ; } "["|"]"|"{"|"}" { (reverse) ? maketd("a0") : maketd("60") ; } "<"|">"|"("|")" { (reverse) ? maketd("c5") : maketd("50") ; } "i"|"l"|"1"|"|"|"!" { (reverse) ? maketd("d0") : maketd("40") ; } ":"|";"|"+"|"~" { (reverse) ? maketd("e0") : maketd("30") ; } "^"|"\"" { (reverse) ? maketd("e7") : maketd("27") ; } "-"|"_" { (reverse) ? maketd("ff") : maketd("20") ; } "'"|"`" { (reverse) ? maketd("ff") : maketd("20") ; } "."|"," { (reverse) ? maketd("ff") : maketd("20") ; } {ws}"\n" { printf(" ") ; printf("\n") ; } " " { maketd("00") ; } . { fprintf(stderr, "Warning: Character %s is not recognized.\n", yytext) ; fprintf(stderr, "Choosing a medium color!\n") ; maketd("97") ; } %% void yyerror(char *msg) { fprintf(stderr, "^GError :\tLine %d: %s at '%s'\n", yylineno, msg, yytext) ; } int yywrap() { return (1); }


Including Graphics in Linuxdoc SGML

From: Martin Michlmayrtbm@cyrius.com
Date: Thu, Apr 17, 1997 at 07:48:19PM +0200
You can already include PostScript images in Linuxdoc-SGML which will get included in TeX output (and consequently in DVI and PostScript). Linuxdoc-SGML doesn't support images for HTML, however.

An example:

<figure>
<eps file = "neuro">
<caption><label id = "decade">
Decade of the brain
</figure>

You can make references to the figure with <ref id="decade">

PostScript is already supported and the developer version of SGML-Tools (the successor of Linuxdoc-SGML) now supports HTML as well. You can specify a PostScript and a GIF file and depending on the output (TeX or HTML) the respective image will be included.


X Configuration Issues

Date: Wed Apr 2 12:15:54 1997
From: Michael J. Hammel, mjhammel@emass.com

If you get sufficiently tweaked by the X monitor config problems, I suggest X Inside's AcceleratedX package. Its much simpler to configure than the XFree package for both cards and monitors. I used to work for them, but haven't in over a year. I still use their package because its the easiest to handle all the video card/monitor details.

BTW, the monitor setup is menu based. If your monitor is not listed you can just use one of the multisync if single frequency generic configs. No dot clocks, but you do need to no your monitors frequency capabilities. These should be listed in the monitors cdocumetntation.

The package is a commercial distribution and runs about $100 (last time I checked). They change their name to Xi Graphics recently and the domain for xinside.com might not be working right now. Try http://www.xig.com.

-- Michael J. Hammel


Multiple X Displays

Date: Wed Apr 2 13:38:08 1997
From: Michael J. Hammel mjhammel@emass.com

Setting up the software is probably fairly straight forward. I've never used MetroX (I use AcceleratedX instead), however. Basically you'll have two choices:

  1. Multiple displays (host:0.0 and host:1.0)
  2. Multiple screens of the same display (host:0.0 and host:0.1)

The second choice is the one you need if you want to move the mouse between the two monitors - like when the mouse goes past the right edge of the first monitor it shows up on the left edge of the second monitor. You'll have to check with Metro to find out which of these options is supported and how to configure for it.

The hardware problem is tougher. The problem lies in the fact that PC's were not originally designed with the idea that multiple display adapters would be installed. The BIOS looks for an adapter at certain locations (IRQ, I/O address) and, unless the second card is configurable to some other address, the system will find multiple cards. What happens next is in-determinant. Some systems won't boot. Some do but don't display to either monitor correctly.

The trick is to find video adapters that were designed to be used in conjunction with other video adapters. Many are not. The easiest way for you to find out is check with Metro about what combinations of video adapters they know work together. Chances are good the ones you have don't. I know X Inside had a list of cards they knew work together. You could search their web site (http://www.xinside.com or http://www.xig.com) and see if that info is still there.

Hope this helps.

-- Michael J. Hammel


Color Depths with X

Date: Wed Apr 2 13:27:40 1997
From: Michael J. Hammel mjhammel@emass.com
After fiddling with the xf86config file in a concerted effort to coax X into displaying 16 bit color, I was dismayed to learn that with my current hardware (16 megs RAM and a Cirrus Logic GL-5426) 16 bit color is *impossible*...not because of any hardware in-capability, but because of a certain limitation of X Windows itself...a problem with linear addressing. Seems that to have 16 bit color under X, one must have linear addressing enabled, which only works if the system has *no more than 14 megs RAM*.

Horse hockeys. 16 bit color is a limitation of the video subsystem and has nothing to do with the memory of your system. Linear addressing in the XFree86 X servers might be tied to system memory amounts, but that would be a limitation in the XFree86 server, not in X. X defines "method without policy", so such limitations just aren't built into X.

A couple of things you should note: The number of colors available under 16bit displays is actually *less* than the number available to 8bit displays. Why this is true has to do with the way 16bit display hardware works. The actual color palette for 8 bit displays can have millions of colors - it can only display 256 colors at a time, however. Frugal use of colormaps can allow you to have nearly exactly the right colors for any given application. 16 bit displays only have a palette of 65k (roughly) colors. Once those are used up, you're outta luck.

I'm not completely clear on what makes this difference such a problem but if you visit the Gimp User's mailing list (see the Linux Graphics mini-howto: http://www.csn.net/~mjhammel/linux/lgh.html) and ask this question you'll get similar replies. Its been discussed quite at length on the developers list, and most of them read the User's list.

BTW, if you want to see if Linear Addressing is the real problem, try the X Inside AcceleratedX demo server and see if it works in 16 bit color for you. Generally, your video card needs at least 1M of on board RAM (not system memory - this is video memory on the video card) to run in 16Bit mode, but then you'll probably only be able to run in 640x480 or (at most) 800x600 resolution. To run at higher resolutions you'll need more video memory.

Hope this helps.

-- Michael J. Hammel


Figuring Out the Boot Process

Date: Fri, 04 Apr 1997 13:20:40 -0600
From: David Ishee dmi1@ra.MsState.Edu
One of the things that is confusing about Linux at first is which files Linux uses to load programs and get the system started at bootup. Once you figure out which programs are run during the boot process, which order are they run? Here is an easy solution.

On my Red Hat 4.0 system, the /etc/rc.d directory tree is where everything happens. There are a lot of shell scripts in this set of directories that are run when the system boots. To give yourself a little more info, add some echo statements to the files. For example:

edit /etc/rc.d/rc.sysinit and add the following lines at the beginning

echo " "
echo "**** Running /etc/rc.d/rc.sysinit ****
echo " "

Now when the system is booting you can see exactly when rc.sysinit is run, and what programs it launches. Repeat the above process for all the scripts you find.

Now if the system hangs or gives an error during bootup you have a better idea of where to look. If you don't have any problems while booting then at least you have more info about what Linux is doing.

David


ftping Home

Date: Thu, 3 Apr 1997 20:38:02 +0300 (EET DST)
From: Kaj J. Niemi, kajtzu@4u.net
I read your article about ftping home with dynamic IPs.. Here's something you might need if you get tired of looking at the screen every time you want to find out the IP.

ADDRESS=`/sbin/ifconfig | awk 'BEGIN { pppok = 0}
                          /ppp.*/ { pppok = 1; next }
                          {if (pppok == 1 ) {pppok = 0; print} }'\
                          | awk -F: '{print $2 }'| awk  '{print $1 }'`

Just replace the ppp.* with whatever you want (if you have multiple ppps running). The easiest thing would to be write a script called ftphome (or similar) and make it first assign the address and then doing ftp or ncftp $ADDRESS. The snippet is originally from a local firewall, at the part where it needs to know what its' own address is. :-) A friend of mine at mstr@ntc.nokia.com wrote this for me.

-- Kaj J. Niemi


Published in Linux Gazette Issue 17, May 1997


[ TABLE OF 
CONTENTS ] [ FRONT PAGE ]  Back  Next


This page maintained by the Assistant Editor of Linux Gazette, gazette@linuxgazette.net
Copyright © 1997 Specialized Systems Consultants, Inc.