ALINK="#FF0000">

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


More 2¢ Tips!


Send Linux Tips and Tricks to gazette@linuxgazette.net


Contents:


Linux - 2 Cents about vim for pico users

Date: Mon, 5 Jan 1998 23:07:20 +0100
From: Sven Guckes guckes@math.fu-berlin.de

I just read the "2 cent tips" again and I thought you might enjoy this tip:

Several people enjoy the editor "pico" but do not feel comfortable with an editor like "vim" for several reasons - one of these being that it is so easy to do reformat the current paragraph with ^J (control-j) within pico while it is so "difficult" within Vim. Well, all it takes is two mappings for Vim:

	nmap <C-J> vipgq
	nmap <C-J>    gq
Put these mappings into your setup file (on Unix and esp Linux this is ~/.vimrc) and you can use ^J to reformat the current paragraph or the currently highlighted text (use 'V' and some movement commands to do that, for example).

More tips can be obtained from these Pages:

	http://www.vim.org/		Vim Home Page
	http://www.vim.org/faq/		Vim FAQ
	http://www.vim.org/answ.html	Vim Answers Page
					(for everything not yet in the VIM FAQ)
	http://www.vim.org/rc		Sven's Huge Setup File with comments
And for those people who use "some vi" but never got the hang of it - here is a page about "why" you would want to use a vi clone such as Vim:
	http://www.vim.org/why.html
Enjoy!

Sven


My 1/50th of a Dollar

Date: Wed, 07 Jan 1998 01:27:09 +0000
From: Michael Katz-Hyman mkatshym@erols.com

Here is a small shell script I wrote to blink the scroll lock on my keyboard when new mail arrived.

--------------------------------------------------------------

#!/bin/bash
#
# Keyboard blinky thingy when you have new mail, sleeps 5 minutes if you
don't
#
# Michael Katz-Hyman (mkatshym@erols.com) running Linux 2.0.33 Red Hat
4.0

Mail_File = "/var/spool/mail/mkatshym"

# The static file is used to make the script a daemon (I just test to
see if  /bin/bash is present :- )

Static_File="/bin/bash"

LED_SET_COMMAND_ON = "/usr/bin/setleds +scroll"

LED_SET_COMMAND_OFF = "/usr/bin/setleds -scroll"

Sleep_Command = "/bin/sleep 2m"


# O.k. lets get started

while [ -e $Static_File ]; do
        while [ -s  $Mail_File ]; do

                $LED_SET_COMMAND_ON
                $LED_SET_COMMAND_OFF
        done

        if [ ! -sMail_FIle ]; then

                  /bin/sleep 5m
        fi
done
------------------------------------------------------------------

Michael Katz-Hyman


sound problems

Date: Wed, 7 Jan 1998 09:48:10 -0600 (CST)
From: Mike Hammel mhammel@stassw10

> Have installed RedHat 5.0 and configured the sound card using sndconfig.
> All went well and I heard the demo sound bite of Linus. However, I
> have never heard another sound since. When browsing web sites with sound,
> no audio is played. Anyone have any ideas? 
First, cat an audio file to the audio device: cat file > /dev/audio. If you get sound out then the device is fine. The problem is probably that you haven't configured your browser to play the audio. With Netscape you would use the Preferences->Navigator->Applications option. You'll need to configure the various audio types to be played using whatever tool you choose (I don't play much audio, so don't have anything configured in my browser to do so). The cat command will work with .au files, and maybe .wav (I think), but possibly not with others. You might want to look at the Linux Application and Utilities Page or the Linux Midi and Sound Page for hints on getting applications for playing sound files. Both of these have links on the Software Resources page at the Linux Journal: http://www.linuxresources.com/apps.html.

Hope this helps a little.

Michael J. Hammel


Filtering output of binary files

Date: Wed, 7 Jan 1998 14:56:05 -0500
From: Sylvain Falardeau sfalardeau@clic.net

When you do a cat/grep/etc. of binary files on a tty, the terminal may become unusable because of some control character.

Guido Socher (eedgus@aken104.eed.ericsson.se) suggests a

sed -e 's/[^ -~][^ -~]*/ /g'

to filter unprintable characters. You can simply use a

cat -v

and all the control characters are escaped to be printable. It's very useful when you are "cating" files and don't know if they contains control characters.


Easter Eggs in Netscape

Date: Thu, 8 Jan 1998 11:53:51 +0000 (GMT)
From: Caolan McNamara caolan@skynet.csn.ul.ie

* From: Ivan Griffin ivan.griffin@ul.ie
*
* These special URLs do interesting things in Netscape Navigator and Communicator.
*
* about:cache gives details on your cache
* about:global gives details about global history
* about:memory-cache
* about:image-cache
* about:document
* about:hype
* about:plugins
* about:editfilenew
*
* view-source:URL opens source window of the URL
*
* Ctrl-Alt-F take you to an interesting site :-)
At least some of the netscape developers have an about for themselves, e.g about:kahern.

C.


RE: Perl and HTML

Date: Thu, 08 Jan 1998 16:58:44 +0000
From: Carl Mark Windsor mbdtscw@cerberus.mcc.ac.uk

In reply to Gabriele Giansante (gvgsoft@madnet.it), whose return mail address does not seem to work.

--------------------------------------------------------------
Gabriele,

The #!/usr/local/bin/perl line is what is used to indicate that this is a perl script, but netscape is not clever enough to know this, it has to be told.

Go to Options / General Preferences / Helpers and edit (if it exists) or create (if it doesn't) the following configuration

Description:  Perl Script
Type:         application/perl
Suffix:       pl
Tick the Application box and put the path
Application:  /usr/sbin/perl   <-----(or the path to your perl)
Sorry if you have heard this all before!

Carl


Update locate

Date: Sat, 10 Jan 1998 19:16:31 +0000
From: Joaquim Baptista px@helios.si.fct.unl.pt

Both Redhat and Slackware (not sure about Debian) install the package updatedb. This package has two programs:

- "updatedb" scans the filesystem and generates a database of existing files.
  This is run every night as root.
- "locate" is run by users to quickly locate files on the filesystem,
  using the database generated by updatedb.
My problem is that "updatedb" runs at 4:40 in the morning, and my machine is rarely running at 4:40. Thus the database is never updated and "locate" never finds any recent file.

The solution is not very simple: updating the database hits the disk hard and takes some time; it is hardly a task to be performed every hour.

My solution is to run a script every hour that updates the database only if it is more than 24 hours old. I (ab)used find to do the task.

Here is the script "run-updatedb":

#!/bin/sh
/usr/bin/find /var/spool/locate/locatedb -mtime +1 -exec \
    /usr/bin/updatedb \
    --prunepaths='/tmp /usr/tmp /var/tmp /mnt /cdrom /floppy /var/spool' \;
I also had to change the crontab for root: I commented the old line that runs updatedb at 4:40, and added a line that runs my script every hour:
0 * * * *   /usr/local/sbin/run-updatedb 1> /dev/null 2> /dev/null
One final note: I believe that both Redhat and Debian have "super-crontabs." That means that you must fish around in /etc (/etc/cron?) for extra crontab files (long live Slackware!).

Best regards,
Joaquim Baptista, alias pxQuim


Doing spaces in file names

Date: Tue, 13 Jan 1998 18:16:48 -0800 (PST)
From: Mark Lundeberg ae885@pgfn.bc.ca

If you think Win95/NT filenames are better than Linux ones, think again. In bash, (this may work in csh, but I never use it) use quotes to enclose the filename in the parameters of a program:

echo "test" > "spaced name"

and do an ls, and you see a space in the middle of the filename! This can be used for confusing people, by going:

echo "Hi" > "test "

(notice the space at the end of "test ").

Then, someone tries to open the file "test" as it looks from ls, but all it does is open a new file.

PS: The ext2 filesystem allows names of up to 255 chars long, just like Loseows 95.

Go Linux!


Mailing binary files to Microsoft clients

Date: Fri, 16 Jan 1998 12:37:22 +0000 (GMT)
From: Ivan Griffin ivan.griffin@ul.ie

Mailing binary files to Microsoft clients...

Quite often I receive a mail with an attachment in that weird Microsoft format which is not quite MIME. It's easy for a Unix client to decode such attachments -- save the message as a file, and run uudecode or the excellent freeware uudeview on it.

However, sending a mail message to such a Microsoft mail user is a little different -- you cannot send them a standard MIME message (unless they are using Exchange I believe). I have found the following script useful in such situations.

Say, for example, I wanted to send a file foo.gif to user mike. I would run my script as follows:

msmail_encode foo.gif > mail_message

Then I would read the mail message into the body of the message I wanted to send. This script could easily be improved to include automatic mailing, and editing of the mail message proper.

#!/bin/sh
echo "[[ $1 : 2628 in $1 ]]"
echo ""
echo " Microsoft document attached. "
echo ""
echo " Regards, "
echo " Ivan."
echo ""
echo "The following binary file has been uuencoded to ensure successful"
echo "transmission.  Use UUDECODE to extract."
echo
cat $1 | uuencode $1  

By the way, I have no idea what the 2628 above refers to. It is a number generated somehow by Microsoft mail clients, but they don't seem to need it, so the 2628 is a value I received once in a mail message.

Regards,
Ivan.


Linux and Routing

Date: Sat, 17 Jan 1998 11:02:43 -0800
From: James C. Carr jccarr@nwlink.com

I am not sure if you have already received a reply regarding your question on routing a LAN to the 'net, so I thought I'd go ahead and give it a shot. The CC to Linux Gazette is just in case no one else has sent in a more elaborate reply. ;) Also, this is something that was mentioned back in Linux Journal number 43 ( November 1997 ), so most of this stems from that particular article, "IP Masquerading Code Follow-UP". To avoid re-hashing someone else's wonderful article, I'll just skim over what I use here at my own home.

======================================================================
Linux and Routing with ipfwadm
======================================================================

Getting Linux to route information between a LAN and the 'net will require you to re-compile the kernel with IP Masquerading support. Of course, one could also use firewalls and disable the routing, but I don't have experience with that just yet. If your kernel version is < 2.0.30, you'll need to enable the "Code Maturity Level" option at re-compilation -- this gives you access to the other Network Options in the kernel, such as IP Masquerading support.

After installing the new kernel, obtain and install the ipfwadm program; this usually comes installed on a base Debian 1.3.1 system, and is easily obtainable for Red Hat. Executing ipfwadm from my end includes the following commands:

	/sbin/ipfwadm -F -p deny
This portion breaks down as follows:

-F -- Notify ipfwadm that you're modifying the IP forwarding rules.
-p -- Tell ipfwadm that you want to deny the forwarding of incoming packets.

I've experienced certain web pages that will not open with this option set; it's probably some Microsoftian plot, you know. ;)

	/sbin/ipfwadm -F -a m -S 192.168.0.0/24 -D 0.0.0.0/0
-F is the same as above.
-a -- Append the following rule to the list, in this case, we're (m) masquerading the following rule.
-S -- We're going to masquerade the computers in the 192.168.0.* address range. Since this is a "local" set of IP numbers, it'll work with all computers on the LAN with these IP addresses.
-D -- The forwarding destination will be 0.0.0.0, the equivalent of the gateway address on a PPP defaultroute.
	/sbin/ipfwadm -F -l -n
Let's make sure this thing is up and running.

-l -- List all IP # forwarding rules;
-n -- convert the information to numeric format.

Of course, you'll need to have assigned your computers with IP addresses within the 192.168.0.* range to use the exact commands above. On my own setup, the primary computer gets 192.168.0.1, and the others fall in succession. Be sure to have all the computers that are being masqueraded set their gateway address to the primary, e.g. secondary.my.com (192.168.0.2) uses primary.my.com (192.168.0.1) as its gateway to the 'net.

For a far more in-depth article regarding this type of set-up, I do suggest reading Chris Kostick's article "IP Masquerading Code Follow-up" in the November 1997 issue of Linux Journal. Not only does it cover the basics, but the author also explains a few more subtle aspects to ipfwadm. Besides, without the help of this article, I wouldn't even know the small amount about ipfwadm that I do. :)

======================================================================

I hope this helped at least a little,

-- James


Linux and Routing 2

Date: Tue, 6 Jan 1998 13:25:57 -0500 (EST)
From: Paul Lussier, plussier@LanCity.COM

> I plan on getting a cable modem soon, so the bandwidth would be pretty
> high, so that is why I have decided to try to make this connection
> provide for my whole house via a LAN connection in my home. What I
> have read is that you could use the private IPs, meaning the 10.x.x.x
> or so, 192.168.x.x and some others for the IP of the LAN and have
> these connect to some box (the LINUX box?) that would provide its
> connection to the internet to the inside LAN connected to the box. Is
> the problem that you would have to route the assigned address to the
> private IPs for the LAN use. I have also read that this would slow
> down the connection a bit or something, but that is a price I am
> willing to pay. So, the summary of the question is how would I be able
> to connect many computers to the internet via just 1 assigned IP
> address? I would like to be able to do it using my LINUX box connected
> to the internet via cable modem, and to my LAN via an Ethernet
> link. Any help is much appreciated, thanks.

This caught my attention, especially since I'm the Unix admin for Baynetworks Broadband Technology Division (formerly LANcity) and we pretty much invented this technology, along with being the leader in the Cable modem industry :) Now that I've got the plug in for company I'll get down to your problem :)

I first must admit that 1.) I don't own a cable modem (I can't get cable, long story :( and 2.) I don't do any routing of this nature. But I have read a lot about it, and I do work with cable modems, so I think I can help a little :)

The first thing to understand is that with Linux, you don't want to be routing, and definitely do not want to run routed to do what you want to accomplish. Rather, you want to be doing IP forwarding/IP masquerading which you would enable in the kernel by re-configuring/re-compiling a new kernel. You'll definitely want to scour the HOWTOs, I believe there is one on this subject. In addition, you may want to check out the Linux Network and/or Systems Administrator's guides, as they too, probably have some good infomation in them. Other good references may be:

The Firewalling and Proxy Server HOWTO is probably the best bet, now that I look, since what you really want to do is set up firewall to prevent people from coming in, and a proxy server to allow your internal lan to get out.

Some words of caution. DO NOT HAVE YOUR LAN CONNECTED AT THE TIME OF THE CABLE MODEM INSTALLATION!!!! MediaOne, Cablevision, Time Warner, and most of the other cable companies (we deal with them all here) will refuse to connect a LAN to their broadband network. Simply remove your hub or coax cable from view, and let them do what they need to do, then connect everything else up after they leave. =20

You will need 2 Ethernet NICs in the system which will be connected to the broadband, one for the cable modem and one for the internal LAN.. Most cable companies will gladly provide and install one for you (MediaOne charges $120 for a 3C509 + labor). I recommend telling them you have a NIC, and going out and buying one and installing it yourself.

The cable modem, in reality, is NOT a modem. It's an Ethernet Bridge. When the modem^H^H^H^H^Hbridge boots/powers up it does a bootp request to a server at the cable companies central office to obtain an IP address. The NIC is also assigned an IP address, which (at least with MediaOne) is registered to the MAC address on the NIC (MediaOne doesn't want you to move the modem to another computer after they leave. They apparently check the modems from time to time to see what MAC they're connected to). Therefore, you want your proxy server/firewall configured so that it prevents all incoming connections from the cable modem and allows only outgoing connections. You want the IP forwarding/masquerading set up to allow other systems on your private lan to use the proxy server as a proxy server (I'm not sure if using the term gateway here is correct).

Some other interesting tidbits of information about cable modems and cable companies:

  1. Do not expect support for running a LAN over the cable modem from the cable company. They don't want you to do it, they won't help you do it.
  2. Do not expect to put up a web server to be accessed by from the internet. You are a client, not a server. This technology,though fully capable of performing in this manner, is not being deployed for use this way. Cable companies WILL shut you down for running a server of anykind on your end of the network, and it can be *forever* :(
  3. Spammers love cable/broadband networks. There have been several cases where a broadband network customer has been used by spammers and were subsequently shutdown for life by the cable company. What happens is the person decides to connect their private LAN to the cable modem but sets the firewall up incorrectly. Spammers search cable/broadband networks for proxy servers/firewalls (Usually Win95/NT) that allow incoming connections and then use that system to spam the entire cable/broadband network making the spam appear as if you sent it. Usually you will be given 1 warning by the cable company, but there have been cases where none was given and the customer was completely shut down.
  4. The current BayNetworks LANcity modems (the LCp product) being deployed in homes is limited to 1 MAC address connection (which means you can't plug the modem into a repeater/mini-hub in order to connectit to multiple systems). It is sotfware upgradable to 16 MACs, but you'll pay a fortune for it to the cable company. However, an ethernet switch works wonders :)
  5. Current modems are capable of transmitting at 10Mbs in both directions, but are usually deployed throttled back to a trasmit speed of 300Kbs and a recieve speed of 1.5Mbs. You want more bandwidth, they'll be happy to charge you more money :)
I hope this helps a little bit. Feel free to e-mail me if you have any questions.

Seeya, Paul


Netscape's Abouts

Date: Tue, 20 Jan 1998 16:00:46 +0100
From: "Stefan K." kampi@physik3.gwdg.de

I've read the article about the about's of Netscape... Here's some more (some of them may not work or simply do nothing)

about:montulli
about:nihongo
about:francais
about:plugins
about:document
about:license
about:cache
about:global
about:image-cache
about:memory-cache
about:security
about:hype
about:blank
about:mozilla
about:security?subject-logo=
about:security?
about:security?banner-mixed
about:security?banner-insecure
about:security?banner-secure
about:security?banner-payment
mocha:
javascript:
livescript:
view-source:
about:FeCoNtExT=123

PEACE!
kampi


Netscape on the Desktop

Date: Sat, 24 Jan 1998 06:46:22 -0500
From: Tim Hawes tim@donet.com

I do a lot of my web development work at home on my Linux box. Netscape for Linux does not automatically check for an existing Netscape session. As a result, if you try to run two different Netscape sessions, you will get an error message box with something like the following:

        Netscape has detected a /home/thawes/.netscape/lock
        file.

        This may indecate that another user is running
        Netscape using your /home/thawes/.netscape files.
        It appears to be running on host localhost under process-ID 316.

        You may continue to use Netscape, but you will
        be unable to use the disk cache, global history,
        or your personal ceritificates.
Blah, blah, blah.

If you are like me, and like to have links to URL's using Netscape on your menus, FVWM GoodStuff or desktop icons, this can be a real nuisance, having to completely start a new Netscape session each time. Or you can have them link with this:

netscape -remote 'openURL(your.url)

But then none of your links will work if Netscape is not currently running. This shell script will look for the lock file that Netscape creates when it is started. If it does not find the lock file, it will start a fresh Netscape session. If it does find it, it will send a netscape -remote command to your current session with the URL you provide in the argument. If you do not provide a URL, netscape will simply give you a popup message indicating that you did not specify a URL. If you do not want Netscape to start up a new window for the URL, just get rid of the "new-window" in the argument in the shell script.

#!/bin/sh
if [ -L $HOME/.netscape/lock ]
        then exec /usr/local/netscape/netscape -remote
'openURL('$*',new-window)';
        else exec /usr/local/netscape/netscape $*;
fi
exit 0
There are limitations with this script. First of all, if Netscape did not exit cleanly after the last session, then the lock file will still be present in your ~/.netscape directory. The script will then try to execute a netscape -remote command and will error out with the console message that Netscape is not running on :0.0. If you are not redirecting your console messages anywhere, then you will not see anything except Netscape not-starting.

1. Do a ps to see if there are any zombie processes left over from your last netscape session.
2. Kill all zombie processes
3. $ rm ~/.netscape/lock
4. retry

I am sure there is a way to automate this through a shell script as well, but I have not yet any time nor motivation to write it. Some other shortcomings include trying to start Netscape composer with the -remote argument for a currently running netscape session. But then this is probably why you should never name a shell script after the actual binary it attempts to start.

All in all, if you envy the functionality of Netscape on Windows 95, automatically checking for an existing netscape session to send the browser surfing, and starting a new session if it does not find it, well, here is a simple solution for Linux users, using the power of the shell.

Tim Hawes


Re: Printing Problems

Date: Sat, 31 Jan 1998 20:09:18 +0100 (MET)
From: Roland Smith, rsmith06@ibm.net

>Anyone that can help me. I'd love to hear it. I try running
>lpr, but everytime I get no name for local machine.
>How do I set this and/or what is the problem.
>Manish Oberoi

It sounds like you're using LPRng. This is a new version of lpr that's more suitable for networks. It is included in the newer Slackware releases and maybe others.

My solution was to grab the bsdlpr.tgz package from ftp.cdrom.com and use that (This is meant for Slackware). Otherwise you can search the Net for "bsdlpr".

-- Roland


Re: Using a 386 Computer

Date: Sat, 31 Jan 1998 20:13:09 +0100 (MET)
From: Roland Smith, rsmith06@ibm.net

>I used to have a 386 25 MHz computer. Not long time ago I bought a
>Pentium 200 MHz computer. Since then I have not played with 386.
>Is there any easy and economical way to connect the 386 to the
>Pentinum computer where I will install the Release 5.0. If so,
>what I can do with it or at lease what I can learn from it.

If you connect both machines with a parallel cable, and configure PLIP into the kernel on both machines, you can have your own little network. A 386 should at least work nice as a terminal, even if it might not run X :-)

-- Roland


Published in Linux Gazette Issue 25, February 1998


[ TABLE OF 
CONTENTS ] [ FRONT PAGE ]  Back  Next


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