[ Prev ][ Table of Contents ][ Front Page ][ FAQ ][ Next ]

More 2¢ Tips!


Send Linux Tips and Tricks to


2c tip: finding out your home router's ip address using lynx

Sun, 7 Jan 2001 13:35:57 -0500 (EST)
matthew willis

Some popular home routers like the Linksys BEFSR41 work well with linux but finding out the external address of the router (e.g. to update some dynamic DNS service) can require manual intervention, like using a web browser and pen and paper. The Linksys device can be automatically queried about its external IP address using the text browser, lynx:

   lynx -auth=\ :admin http://192.168.1.1/Status.htm -dump

You can then parse the output for the IP address you need, using PERL or your favourite scripting tool. For example, here is how I chained sed and awk to find the line "IP Address" that comes in the "WAN" section:

 lynx -auth=\ :admin http://192.168.1.1/Status.htm -dump | sed "1,/WAN/d" | awk -F: '/IP Address/{print $2}'

Note that there is a single space between "\" and ":admin".

- Matt Willis


2cent tip Available space available on Hd - follow up

Sat, 6 Jan 2001 06:43:49 -0800
Ted Potter

yes and for those of us who can not do the math include the -h command line option!

here -

 df
Filesystem           1k-blocks      Used    Available  Use% Mounted on
/dev/hda1              2028098   1603178    320098      83% /
/dev/hda3              9991422    607203   8865722       6% /home
/dev/hdb                 60334     60334         0     100% /mnt/cdrom

 df -h
Filesystem            Size  Used   Avail   Use% Mounted on
/dev/hda1             1.9G  1.5G  313M      83% /
/dev/hda3             9.5G  593M  8.5G       6% /home
/dev/hdb               59M   59M     0     100% /mnt/cdrom

-- Ted Potter


Tech tip -- removing all files except *.c

Mon, 15 Jan 2001 13:10:40 -0800
Jane Liu

I have a question about rm command. Would you please tell me how to remove all the files excepts certain files like anything ended with .c?

The easiest way (meaning it will work on any Unix systems anywhere), is to move those files to a temporary directory, then delete "everything", then move those files back.

mkdir /tmp/tdir
mv *.c /tmp/tdir
rm *
mv /tmp/tdir/* .
rmdir /tmp/tdir


netscape to read html files ( $0.02 )

Sun, 07 Jan 2001 02:13:27 -0500
Allan Peda

I usually have netscape open, and I also have several terms open, also some files only have html documentation (e.g., htdig ). I added this bash function to my .bash_profile to send a file to netscape at the command line. (for a list of the options type netscape -help):

function ns () {
    if [ "." = "$(dirname $1)" ]; then
        argpath=$(pwd)
    else
        argpath=$(dirname $1)
    fi
    url_arg=${argpath}/$(basename $1)
    netscape -remote "openURL(file://$url_arg)"
    unset argpath url_arg
}

export -f ns

So for README its :

me@box] vi README

but for README.html

me@box] ns README


Need info (Need Outlook to speak to Linux) (Issue 61, 2 cent tips)

Tue, 02 Jan 2001 21:28:03 -0500
Anthony E. Greene

...no less than 5 people mentioned...

It sounded like the poster wanted to provide native MS Exchange services using a UNIX/Linux server. If so, she should look into HP OpenMail (http://www.hp.com/go/openmail).

Anthony

... P Kelly from pksings.com cared to add...

HP openmail, free for under 50 users. Not super easy to install but free....

PK


2-cent tip - module resource detection

Mon, 22 Jan 2001 10:58:20 -0800
Ben Okopnik

We started doing something interesting in Tips - we have some good scripts to do nice little things. But, a lot of people have reported difficulty doing the necessary cut-and-paste. So I'm sure you'll be glad to know that a number of these will now be completely seperate files with a .txt extension, so that they can be downloaded safely.

Tip: As long as you have a #! line, linux doesn't care in the least whether the filename has a reasonable extension... or any at all, for that matter.

Here's the popularly requested resource detection script.

See attached misc/tips/shotgun.bash.txt


8 Cents Worth

Tue, 16 Jan 2001 13:56:39 -0500
Heather

[near the tail end of a thread where we are being really careful with rm]

[Dan] It would be prudent to try the thing out in a directory containing only expendable files with names similar to the intended victims/saved.

[Dan] I've more than once had to resort to backups due to a slip of the fingers (the brain?) with an "rm" expression.

Note that he actually has known good backups to resort to.

[Heather] tip: echo (rest of command)

will reveal what globbing is about to inflict on you. Won't solve everything, but at least you'll be safe from the shell's perspective.

[Ben] Good call! It's also well worth checking out the "shopt" built-in command, particularly the "extglob" and "nullglob" options (I sort of wonder why "bash" doesn't default to those being on); they can make dealing with globbing a slightly friendlier experience - as well as slightly more intuitive, in my opinion.


Shebang problems

Sat, 20 Jan 2001 16:54:52 +0100
NLH AS

You have a question & answer on Linux Gazette with title:

shell cannot see an existing file --or-- ./script: No such file or directory

One possibility you don't mention, which I've just found out the hard way (ie. by using a lot of time) is that the file should not have been written with a dos/windows editor (eg. on a samba share). CRLF at the end of the shebang line causes exactly the chain of frustrations your correspondent describes -- as far as I can be bothered to test (more time) this seems to be completely consistent for bash and python scripts with a shebang line.

Oddly enough removing the shebang line makes the thing work -- the shell exec() which you also describe is not CRLF sensitive.

Paul Mothersdill


about Unix command ps

Fri, 26 Jan 2001 14:24:31 -0800
Jane Liu

Is there a way to find out the date when a process is created?

"ps aux" shows the date and a lot of other information as well. You can use

ps aux | grep DESIRED_COMMAND_NAME

to filter out unwanted processes, or specify the process ID as

ps aux 1234

...so, she tried that, but it wasn't what she needed...

I am using HP unix. ps -aux is the same as ps. It gives only the execution time, but not the elapse time. Any other options?

ps has a bazillion options; see if elapsed time is listed in the manpage.

If the process hasn't started yet and you don't need the time until after it's over, there's the "time" command.

-- Mike Orr


Linux security FAQ

Tue, 2 Jan 2001 08:43:51 -0800
Anonymous Coward

The Linux Security FAQ has been slashdotted.

http://www.linuxsecurity.com/docs/colsfaq.html


renaming directories

Wed, 03 Jan 2001 19:45:46 -0600
k.s. yeriazarian

how do you rename/change names on directories? thanks

Use the 'mv' command.

Please send follow-ups or future questions in text format rather than HTML. It makes it easier to read them.


hi im a moron

Sun, 28 Jan 2001 19:51:20 -0800
luciferxe

On Sat, Jan 27, 2001 at 01:22:57AM -0500, . wrote:

hi im just wondering how to make a swapfile on my linux sys

I beg to differ about that "moron" part. After all, you knew enough to ask a question in the right place!

I'm assuming you really want a swapfile, as opposed to a swap partition.

A swapfile will be slower than a partition, but it can be a handy thing for that sporadic task that really chews up memory.

The way I usually do it is first to make a zero-filled file of the desired size using "dd":

  dd if=/dev/zero of=/usr/tmp/newswapfile bs=1024 count=65536

for a 64M swapfile. Vary "count" as desired. Then

  mkswap /usr/tmp/newswapfile
  swapon /usr/tmp/newswapfile

If you wish to have the swapfile mounted at boot time, find the appropriate place in your init scripts and add the "swapon" command.

See "man mkswap", "man dd", "man swapon" for more info on swapfiles.

-- Dan Wilder


tar on remote file system ...

Mon, 15 Jan 2001 17:27:47 -0500
Hansjoerg Graesslin

On Mon, Jan 15, 2001 at 07:16:28AM +0000, Hansjoerg Graesslin wrote:

Hi, I read your article about making backup to remote tape devices, but is there any way to make a backup on a remote file system with the tar command ??

I tried :


tar czSf - test | rsh -l operator remotehost

and get something strange ...


$ tar czSf - test | rsh -l oracle skye
tar: z: unknown option
Usage: tar {txruc}[vfbFXhiBelmopwnq[0-7]] [-k size] [tapefile]
[blocksize] [exc.
tcgetattr: Invalid argument
ioctl I_PUSH ttcompat: No such device or address
$

That's not particularly strange, given that you seem to be using something other than GNU tar. There are many different versions out there; which one do you have? GNU's version has supported "z", the "filter through gzip" switch, since at least early 1997, when I started using it. So, what's happening above is that "tar" fails with fireworks - and pipes something of that to "rsh", which also explodes and screams in agony (hmm. Too many Schwarzenegger movies lately, I guess.) A hint for next time: when you have a problem that involves several programs. separate them in order to find out which one is giving you a problem (or at least, which problem.) It's much easier to troubleshoot things that way.

any ideas ??

Yes. Go to http://www.gnu.org and download the latest version of "tar". Compile it, run it, and if you encounter any problems at that point, write to us again. This time, include the versions of both "tar" and "rsh", as well as which distro and version of Linux you're using. I have a feeling, though, that the first suggestion will fix the problem.


Your article in Linux gazette

03 Jan 2001 19:32:03 +0200
Jani Grönberg

Hi,

I scanned through your article in Linux gazette today, and having used a configuration similar to this about a year ago, I thought that you might appreciate this information:

Lilo can write the boot sector information directly to a file so the stuff with lilo.dummy and dd is not necessary. E.g. in my configuration, /dev/hda1 contained a vfat partition including the NT loader (mounted to /dos in linux). I had the line:


boot=/dos/bootsect.lin

in my /etc/lilo.conf and provided that the partition is mounted and a file exists (first time do "touch /dos/bootsect.lin") it should work (unfortunately I'm currently using a different configuration so I can't verify if i forgot something).

There can be issues if you have a large hard disk and the linux kernel is not in the beginning; these are better covered in other documents, but to avoid these I also copied my kernel to /dos/linux/vmlinuz. I'm not sure if these are still valid with the current versions of lilo, though.

//jani


Diald and AIM

Fri, 19 Jan 2001 19:37:26 -0600
Michael Ikemeyer

Answerguy,

I've notice a strange anomaly in the last couple of months when using DIALD to connect to any local ISP. I have a simple setup, boxA (the MASQ, RedHat 5.2) and boxB (private IP, Win98). Everything works great except when I try to use AOL's Instant Messenger. Upon starting AIM the usual happens... Connecting.... Verifying username and password... Starting services.... then the roadblock of "Connection lost. Check your Internet connection". Viewing my log files I get "kernel: MASQ: failed TCP/UDP checksum from 64.12.24.172". However, if I dial up any ISP with a normal pppd script (less the SLIP interfaces involved for diald) it works. At this point I'm not sure what I need to do to resolve this problem. Have any ideas?

Thank you, Michael

... but he solved it!

Answerguy,

I have resolved my problem by passing the following to pppd when starting diald...

/usr/sbin/diald -f /etc/diald/diald.conf -- asyncmap 20A0000 escape FF


Geforce2 and X 4.0.1

Wed, 3 Jan 2001 10:30:32 -0400 (VET)
Ernesto Hernandez-Novich

Lots of people sent help about the Geforce card! Thanks bunches! -- Heather

...

Regarding Ron Nicholls question in "The Mailbag" (January 2001) on using an nVidia Geforce2 card under XFree86 4.0.1

As of today, he has two alternatives:

1. He can download the binary drivers provided by nVidia, which are

designed to work in 4.0.1 replacing XFree's drivers. These drivers will give him improved 2D acceleration and 3D acceleration via GLX. I've been using this setup with an nVidia RIVA TNT2 and a Geforce2 GTS (both 32Mb) with no problems whatsoever.

...another reader noted that the driver has to be compiled to match your kernel version. He must be using the source rpm, I think - Gustavo Alday found a complicated URL which seems to hit paydirt:

http://www.nvidia.com/Products/OpenLinuxDwn.nsf/b99b7f622d429347882568c800771b6c?OpenView&Start=1&Count=30&Expand=2#2

2. He can grab 4.0.2 (compile it himself and/or get binaries) for

very decent 2D acceleration for any nVidia card, including GeForce2s. I tried this the day after 4.0.2 but unfortunately had trouble getting the GLX extensions to work so I switched back to 4.0.1

...Michael Coyne (michael from coyne.tc) noted that Mandrake 7.2 autodetected his card, though he suspects DRI support isn't active, and that he has used his card happily on a continuously upgraded RedHat system with the generic nvidia server.

The instructions included with the nVidia drivers are more than enough to get it to work, so check out the drivers at

http://www.nvidia.com/Products/Drivers.nsf/Linux.html

Hope this helps.

And to the nVidia people: ˇPLEASE OPEN UP YOUR DRIVERS! -- Ernesto Hernández-Novich

...ah, but Ryan Phillips (ryan.phillips from csus.edu) seems to have exactly what our querent wanted; the same system in good working order, and a pointer to a URL describing how:

http://www.evil3d.net/articles/linux/howto/nvidia/redhat7

Thanks again, everyone!


Setting up print filters

Wed, 3 Jan 2001 16:00:51 -0700
Simeon ben Nevel

Hi Answer Folks!

In issue 61 there was an Answer Guy question on getting an Epson Stylus 670 to work under linux.

Making color printers work seems to be a very common question on the various linux fora and newsgroups with very few answers forthcoming.

I'd like to recommend turboprint from http://www.turboprint.de

It supports a wide variety of Epson, Canon and Hewlett-Packard color printers (including my Canon BJC-3000!).

It's currently at version 0.70 and is free (as far as I can tell from the web-site). No source is provided however.

It installed quite easily from a tar-ball and works like a dream for me.

The install process will even "probe" your system looking for "helper" programs (like enscript, a2ps or html2ps) that the filter uses to handle various sorts of files and let you know what you're missing.

(Actually finding RPMs for the various pieces and getting the dependencies resolved is another issue entirely <g> ;)

You can set up multiple configurations for a single printer to handle different print media (plain paper, glossy paper, transparencies), different print media sizes, different resolutions and has a whole range of other adjustments for color saturation and absolute page positioning.

The latest version even has a couple of graphical (gtk based I believe) application to do the configuration in addtion to ncurses based tools.

Best of all, the fellow who created turboprint answered my dumb configuration question very promptly and in English!

There is also http://www.linuxprinting.org with a wealth of other information. (Hmm.. I couldn't get there just now <shrug> ;)

You might also check out the Linux Hardware Database at:

http://lhd.datapower.com

Which has a section on printers.

I hope this information is useful.

Simeon ben Nevel --


More e2label scripting

Sat, 30 Dec 2000 14:36:05 -0500
Allan Peda

I was not satisfied with the label display script that I wrote and sent in about 1 week ago because it ignored SCSI devices. This one should be a little more generic.

Allan

See attached misc/tips/label.sh.txt


RE: reading a number in a bash shell script. Here is my final sc

Thu, 11 Jan 2001 13:21:39 -0500
Steven Kladitis

My name is Steven and I was wondering if there is an easy way in a bash shell script to tell if the variable you read is numberic?

For example

#!/bin/bash
#set -x

Just a comment here: the above line is unnecessary. The "-x" argument can be used with "/bin/bash" directly to get the same effect.


echo -n 'Enter a number '
read x
????????????

How can I tell if $x is numeric easily? I have read and reread the docs, but I see no number test. I was thinkg about trap but I do not understand how it works.

'trap' has no relation to what you're trying to do; it deals with signals. Here is what you want:

[ $(echo $value|grep -c "[^0-9]") -gt 0 ] && echo "Not a number."

We simply ask "grep" to check for the presence of non-numeric characters, and echo a message if they're present.

Shell variables can be declared as numeric via the "declare" or "typeset" commands; they do fairly well with strings like "abCD43" by reading them as 0, but fail, very loudly, on strings that start with a digit:

value too great for base (error token is "3x")

The "grep" test always returns sensible output.

-- Ben Okopnik

This script will read a tnsnames.ora file ( Oracle stuff ) and connect ou to the appropiate instance in sqlplus. Thanks for your help!!!

Steve

See attached misc/tips/spdist.bash.txt


RE: Trident NTSC drivers

Tue, 30 Jan 2001 17:21:23 -0600
Darrick Hartman

Heather--

Since I wrote [asking after the trident drivers] I discovered that no additional drivers are needed. What I DID find is Trident's manual is WRONG about the jumper on the card. It says it needs to be off to auto detect whether the card is connected to a vga or composite video device. In fact, it needs to be ON...jumpered to work correctly. Exactly opposite of the manual. If this helps someone, please pass it along.

Later--

Darrick


A rather unique query -- solved!

Tue, 02 Jan 2001 11:31:44 -0800 (PST)
Karen Gartner

First - THANK YOU to everyone who made suggestions and offered expertise on solving this problem. I was just mucking about in my linux directories - searching for config files when ...

The SOLUTION: Install the GL1 driver package as is. Copy the actual driver file "firegl1" to /dev. Pico XF86Config-4, add the driver name to the video card device, and change the default video depth to 24. Then run startx at the command prompt and inko presto - graphics!

Now I don't have to worry about changing the kernel - thank heavens!

Thank you all so much! Karen Gartner


Shebang problems

Sat, 20 Jan 2001 16:54:52 +0100
NLH AS

You have a question & answer on Linux Gazette with title:

shell cannot see an existing file --or-- ./script: No such file or directory

One possibility you don't mention, which I've just found out the hard way (ie. by using a lot of time) is that the file should not have been written with a dos/windows editor (eg. on a samba share). CRLF at the end of the shebang line causes exactly the chain of frustrations your correspondent describes -- as far as I can be bothered to test (more time) this seems to be completely consistent for bash and python scripts with a shebang line.

Oddly enough removing the shebang line makes the thing work -- the shell exec() which you also describe is not CRLF sensitive.

Paul Mothersdill


How to hack a proxy (LG #53, Query number 16, I think)

Wed, 24 Jan 2001 14:04:50 +0400
Faisal Halim

Dear Iman,

I would suggest you visit http://www.anonymiser.org or http://www.privatesurfing.com and use their free service. But be careful, your administrator gets suspicious, and even these sites can get blocked. [That is a risk I have to live with when using my ISP-Emirates Internet and Multimedia.]

You can use a good search engine like http://www.google.com and enter "anonymiser" in the search box. Or better yet, use this search engine to search for your topic of interest, and retrieve your page of interest from Google's cached pages. Since Google will fetch the page for you, your proxy will 'be tricked into thinking you are receiving a page from Google'!

Alternatively, you could use one of the online web page caching servers (search for "free ISP" on Google's search engine) to fool your proxy server in a similar way.

And here is a method my friend claims to have used, but I never tested myself. I don't even know the legal implications of using this system. do this at your own risk. Set your http proxy to one that is outside your network. That way, (theoretically) you will use your local network proxy to access the net, use the net to access this other proxy, which in tern you will use to access the hackers' sites.

You might have noticed (and in fact you should have noticed by now, that using any of the methods I gave you, you will simply fool your network proxy, not crack it.

You Wanted To Crack, Not Hack There are great differences between hacking and cracking. Please check out the page, "How to become a Hacker" at http://www.tuxedo.org

Salaam, and Goodbye Faisal Halim


bogo

Tue, 2 Jan 2001 08:44:46 -0500
Kurt V. Hindenburg

Hello,

I tried your little bogo script. I installed bing-1.1.3 and traceroute -1.4a7. However ,when I execute the bogo script I get the following:


(kvh)-(20:15)-(~)> ./bogo

real 0m24.083s
user 0m0.010s
sys 0m0.000s

Ping time to ISP: ms
Measuring speed...

If you take a look at the script itself, you'll note that the comment immediately following the script description tells you to change the default ISP name (www.mindspring.com) to your own ISP's URL. Also note that in my 2-cent tip I wrote:

"... it prints the time that is required for the first 'ping' to reach your ISP, as well as the time that it takes to execute that ping. In my experience, if that execution time is much longer than 3 seconds, you've got a poor connection and should try redialing."

24 seconds, as your output above shows, is quite a bit longer than 3 seconds. What it's saying is that the ping is probably not getting through to MindSpring (unless you've modified $ISP) at all - most likely, it's timing out. I recommend that you 1) replace "mindspring" with your ISP's URL, and 2) ping that URL once you're connected to see the results.


Ben_Okopnik

Tue, 2 Jan 2001 11:50:01 -0500
Werner Gerstmann

Werner Gerstmann wasn't the only person who asked what 'bing' was, but he did have a curious reason to be unsure:

Hallo Ben,

in #61 of LG I found some nice scripts of yours. One question: in the one for measuring a modem connection, a progamme's name is "bing" or "ping" ?? For me it's a bit funny, because in Germany we have a regional slang (the Saxons), they cannot distinguish "d" and "t" or "b" and "p" (the soft and the hard ones), but normally only if they speak ! ! If "bing" is correct please give me a hint where to find it.

Regards Werner

It's "bing", an "empirical stochastic bandwidth tester" as its author calls it, with the 'b' coming from the term "bandwidth". I just think of it as a smarter "ping". In Debian, it's part of the distribution, as part of the "net" category; their source for it was 'bing_1.0.4.orig.tar.gz', available at their site.

<ftp.debian.org/debian/dists/potato/main/source/net/bing_1.0.4.orig.tar.gz>


Measure your modem connection - Bogospeed

Sat, 20 Jan 2001 10:50:27 -0500
Joe St.Clair - KSI Machine & Engineering

On Sat, Jan 20, 2001 at 10:27:14AM -0500, Joe St.Clair - KSI Machine & Engineering wrote:

What it "bing" that is needed for the "Bogospeed" script?

A lot of folks have written in to ask this same question. I'll admit to being a bit surprised, but here's some easily-retrieved info.

A search on Google for "bing and linux" brings up over 10,000 hits. The very first of these says

"Debian GNU/Linux -- bing Package: bing 1.0.4-5.3.1. Empirical stochastic bandwidth tester."

For those of you who are left as unenlightened by this as I was, it's just a fancy way of saying "a smarter version of 'ping'".

Yep; that's the dude. In fact, due to the fact that the author of "bing" has unaccountably changed the entire syntax and output of "bing" with the new version, the only one that will work without modifying the script is version 1.0.4. It's easy enough to download and install. <grin> For anyone who has read my series on shell scripting here in the LG, modifying it for the new version should be a trivial task.

As well, here is the "new and improved" version of the "speed" script; due to feedback from several of our readers, I've generalized the IP/time parsing routine, which should make it a bit more useable.

I took the liberty of promoting the warning comment to an actual message, in case anyone finds it useful enough to leave lying around. -- Heather

See attached misc/tips/speed.bash.txt


This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 62 of Linux Gazette February 2001
HTML script maintained by of Starshine Technical Services, http://www.starshine.org/