Linux Gazette Mailbag LG #67



Send tech-support questions, answers and article ideas to The Answer Gang . Other mail (including questions or comments about the Gazette itself) should go to . All material sent to either of these addresses will be considered for publication in the next issue. Please send answers to the original querent too, so that s/he can get the answer without waiting for the next issue.

Unanswered questions might appear here. Questions with answers–or answers only–appear in The Answer Gang, 2-Cent Tips, or here, depending on their content. There is no guarantee that questions will ever be answered, especially if not related to Linux.

Before asking a question, please check the Linux Gazette FAQ to see if it has been answered there.

envelope-8884608 ip_always_defrag missing from kernel 2.4?

Thu, 10 May 2001 11:04:18 -0500
James Garrison (jhg from athensgroup.com)

In its place there appear to be three new parameters:

ipfrag_high_thresh – INTEGER

Maximum memory used to reassemble IP fragments. When ipfrag_high_thresh bytes of memory is allocated for this purpose, the fragment handler will toss packets until ipfrag_low_thresh is reached.

ipfrag_low_thresh - INTEGER
See ipfrag_high_thresh


ipfrag_time - INTEGER
Time in seconds to keep an IP fragment in memory.

Any idea what are ‘reasonable’ settings?

What settings will mimic, as closely as possible, the behavior of ip_always_defrag?

— James Garrison

envelope-8884608 ‘Spanking New’ Distribution ships with ‘development’ compiler

Mon, 21 May 2001 21:01:52 -0400
Marc Doughty (mdoughty from etal.uri.edu)

Hello TAG-Team,

I just installed Mandrake 8.0. I intend to use gcc (the compiler) quite a bit to recompile lots of software. Mandrake 8.0 ships with a development version of gcc (2.96) but I really want to stick with 2.95.x for stability/portability. How can I remove the development-gcc and put an older version in without breaking the system. I know there must be a way to do this via RPM, but it eludes me and I was seriously frightened to rebuild from an unmanaged source tarball.

-Marc Doughty

envelope-8884608 Printer memory overflows

Sun, 20 May 2001 12:46:11 -0400
Jonathan Markevich (jmarkevich from mad.scientist.com)

I just got an older laser printer and it works very well with a HP LJ III printcap setting, except it has only 1 MB of RAM. This works well until I try to print a PDF, then it runs out of printer memory about 7/8 of the way through the page.

Is there some way to tell ghostscript/lpd to go easy on the thing? I was able to print them fine on my inkjet, and it definitely doesn’t have 1 MB of memory installed…

Oh yes, the same .PDF prints fine on the Evil(tm) Operating System.

Thanks.

— Jonathan Markevich

envelope-8884608 What happened to e2compr?

Sun, 20 May 2001 12:23:55 -0400
Pierre Abbat (phma from oltronics.net)

I run Linux 2.2.14 on a laptop with a by now small hard drive. To put some huge files (such as graphics in the middle of editing) on it, I installed the e2compr patch to the kernel. I’d like to upgrade to 2.4, but the patch doesn’t seem to be available for 2.4. Anybody know what happened to it?

phma

There’s at least one new compressed filesystem in the new kernels, but I’m not sure that the one I’m thinking of is realy ext2 compatible. Still, you might not need that. There’s a curious new style of ramdisk available too. Anyone who knows more is welcome to chime in … — Heather

envelope-8884608 Linux fashion

Mon, 21 May 2001 10:39:29 +0200
Erez Avraham (ereza from meetu.com)

Greetings

I’m reading the gazette for a wile now, and never found an answer to my simple question Where can I found Baby’s clothes related to Linux? With Linux logo or something. I want my baby to be cool (and to use Linux) …..

thanks
Erez Avraham

It looks like The Emporium (a UK company) sells child size sweatshirts but I don’t know what sizes are good for babies. Comments welcome. If you are a commercial entity which has ’em, let us know, and we’ll put you in News Bytes. — Heather

envelope-8884608 IRC channels for IPChains

Mon, 30 Apr 2001 15:35:06 -0700
Bettle, Roy (RBettle from lbfc.com)

One more quickie: do you know of any IRC channels where I can get some IPChains questions answered? I’m trying to put in a firewall for a client using a script that has worked very well for me for several years (used to be IPMasq, but has been modified for IPChains) but just dies now and for the life of me I can’t figure out why.

The only difference in this case that I can see is that the DSL line it sits behind is running Ethernet bridging (PacBell DSL) over an Alcatel modem and the script has been running behind a Cox@Home cable modem (no bridging); but why is that such a « deal-killer »?

Anyway, thanks again!

RAB

Roy Bettle

envelope-8884608 Tape Backup

Sat, 19 May 2001 13:25:32 +0800
Desmond (desmond from kikuze.com)

Hi Sir,

Recently,in the pipeline of converting my NT server to a Redhat 7.1 Linux Server with Samba on it. But the problem is I’m using a a HP SureStoreDAT 40 tape Drive. And there is nowhere I can find the driver for this device(including the HP and Redhat website). I really hope that I can realise my dream of setting up 2 Linux server(with UPS and backup tape driver on) at my place. I don’t want to scrap the whole project halfway. Does you knows where I can get the above driver or a generic driver well do? Or is there any recommendations on a almost similar tape drive that is well supported with Redhat? If I can’t succeed then I ‘ll have to go to Windows2000 with all those expensive licenses. Thanks
warmest regards,

READ  The emelfm File Manager LG #61

Desmond Lim

envelope-8884608 Article idea

Mon, 14 May 2001 05:56:21 -0400
Gerspacher, Travis (GerspacherTr from bfusa.com)

Yes, Gentle Readers, this is also in TAG this month, but folks looking for article ideas are encouraged to take this and run with it. For that matter, we have a PostgresSQL related article this month (nielsen.html) but it would be fun to have an article comparing PostgresSQL to MySQL. — Heather

I would love to see an article about making sense of MySQL.Perhaps some basic commands, and how to do something useful with it.

Here are some basic commands. As far as « something useful », what would you consider useful?

I have found a lot of articles either lack basic usage and administration or it it fails to show how to put it all together and have somehing useful come out of it.

The ‘mysql’ command is your friend. You can practice entering commands with it, run ad-hoc queries, build and modify your tables, and test your ideas before coding them into a program. Let’s look at one of the sample tables that come with MySQL in the ‘test’ database. First we’ll see the names of the tables, then look at the structure of the TEAM table, then count how many records it contains, then display a few fields.

$ mysql test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1325 to server version: 3.23.35-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer

mysql> show tables;
+------------------+
| Tables_in_test   |
+------------------+
| COLORS           |
| TEAM             |
+------------------+
2 rows in set (0.00 sec)

mysql> describe TEAM;
+------------+---------------+------+-----+---------+----------------+
| Field      | Type          | Null | Key | Default | Extra          |
+------------+---------------+------+-----+---------+----------------+
| MEMBER_ID  | int(11)       |      | PRI | NULL    | auto_increment |
| FIRST_NAME | varchar(32)   |      |     |         |                |
| LAST_NAME  | varchar(32)   |      |     |         |                |
| REMARK     | varchar(64)   |      |     |         |                |
| FAV_COLOR  | varchar(32)   |      | MUL |         |                |
| LAST_DATE  | timestamp(14) | YES  | MUL | NULL    |                |
| OPEN_DATE  | timestamp(14) | YES  | MUL | NULL    |                |
+------------+---------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

mysql> select count(*) from TEAM;
+----------+
| count(*) |
+----------+
|        4 |
+----------+
1 row in set (0.00 sec)

mysql> select MEMBER_ID, REMARK, LAST_DATE from TEAM;
+-----------+-----------------+----------------+
| MEMBER_ID | REMARK          | LAST_DATE      |
+-----------+-----------------+----------------+
|         1 | Techno Needy    | 20000508105403 |
|         2 | Meticulous Nick | 20000508105403 |
|         3 | The Data Diva   | 20000508105403 |
|         4 | The Logic Bunny | 20000508105403 |
+-----------+-----------------+----------------+
4 rows in set (0.01 sec)

Say we’ve forgotten the full name of that Diva person:

mysql> select MEMBER_ID, FIRST_NAME, LAST_NAME, REMARK

-> from TEAM
-> where REMARK LIKE "%Diva%";

+-----------+------------+-----------+---------------+
| MEMBER_ID | FIRST_NAME | LAST_NAME | REMARK        |
+-----------+------------+-----------+---------------+
|         3 | Brittney   | McChristy | The Data Diva |
+-----------+------------+-----------+---------------+
1 row in set (0.01 sec)

What if Brittney McChristy changes her last name to Spears?

mysql> update TEAM set LAST_NAME='Spears' WHERE MEMBER_ID=3;
Query OK, 1 row affected (0.01 sec)

mysql> select MEMBER_ID, FIRST_NAME, LAST_NAME, LAST_DATE from TEAM
-> where MEMBER_ID=3;

+-----------+------------+-----------+----------------+
| MEMBER_ID | FIRST_NAME | LAST_NAME | LAST_DATE      |
+-----------+------------+-----------+----------------+
|         3 | Brittney   | Spears    | 20010515134528 |
+-----------+------------+-----------+----------------+
1 row in set (0.00 sec)

Since LAST_DATE is the first TIMESTAMP field in the table, it’s automatically reset to the current time whenever you make a change.

Now let’s look at all the players whose favorite color is blue, listing the most recently-changed one first.

mysql> select MEMBER_ID, FIRST_NAME, LAST_NAME, FAV_COLOR, LAST_DATE from TEAM

-> where FAV_COLOR = 'blue'
-> order by LAST_DATE desc;

+-----------+------------+-----------+-----------+----------------+
| MEMBER_ID | FIRST_NAME | LAST_NAME | FAV_COLOR | LAST_DATE      |
+-----------+------------+-----------+-----------+----------------+
|         3 | Brittney   | Spears    | blue      | 20010515134528 |
|         2 | Nick       | Borders   | blue      | 20000508105403 |
+-----------+------------+-----------+-----------+----------------+
2 rows in set (0.00 sec)

Now let’s create a table TEAM2 with a similar structure as TEAM.

mysql> create table TEAM2 (

-> MEMBER_ID int(11) not null auto_increment primary key,
-> FIRST_NAME varchar(32) not null,
-> LAST_NAME varchar(32) not null,
-> REMARK varchar(64) not null,
-> FAV_COLOR varchar(32) not null,
-> LAST_DATE timestamp,
-> OPEN_DATE timestamp);
Query OK, 0 rows affected (0.01 sec)

mysql> describe TEAM2;
+------------+---------------+------+-----+---------+----------------+
| Field      | Type          | Null | Key | Default | Extra          |
+------------+---------------+------+-----+---------+----------------+
| MEMBER_ID  | int(11)       |      | PRI | NULL    | auto_increment |
| FIRST_NAME | varchar(32)   |      |     |         |                |
| LAST_NAME  | varchar(32)   |      |     |         |                |
| REMARK     | varchar(64)   |      |     |         |                |
| FAV_COLOR  | varchar(32)   |      |     |         |                |
| LAST_DATE  | timestamp(14) | YES  |     | NULL    |                |
| OPEN_DATE  | timestamp(14) | YES  |     | NULL    |                |
+------------+---------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

Compare this with the TEAM decription above. They are identical (except for the multiple index we didn’t create because this is a « simple » example).

Now, say you want to do a query in Python:

$ python
Python 1.6 (#1, Sep  5 2000, 17:46:48)  [GCC 2.7.2.3] on linux2
Copyright (c) 1995-2000 Corporation for National Research Initiatives.
All Rights Reserved.
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.
>>> import MySQLdb
>>> conn = MySQLdb.connect(host='localhost', user='me', passwd='mypw', db='test')
>>> c = conn.cursor()
>>> c.execute("select MEMBER_ID, FIRST_NAME, LAST_NAME from TEAM")
4L
>>> records = c.fetchall()
>>> import pprint
>>> pprint.pprint(records)
((1L, 'Brad', 'Stec'),
 (2L, 'Nick', 'Borders'),
 (3L, 'Brittney', 'Spears'),
 (4L, 'Fuzzy', 'Logic'))

Another approach is to have Python or a shell script write the SQL commands to a file and then run ‘mysql’ with its standard input coming from the file. Or in a shell script, pipe the command into mysql:

$ echo "select REMARK from TEAM" | mysql -t test
+-----------------+
| REMARK          |
+-----------------+
| Techno Needy    |
| Meticulous Nick |
| The Data Diva   |
| The Logic Bunny |
+-----------------+

(The -t option tells MySQL to draw the table decorations even though it’s running in batch mode. Add your MySQL username and password if requred.)

‘mysqldump’ prints a set of SQL commands which can recreate a table. This provides a simple way to backup and restore:

$ mysqldump --opt -u Username -pPassword test TEAM >/backups/team.sql
$ mysql -u Username -pPassword test