More 2 Cent Tips & Tricks LG #61

Rate this post



Send Linux Tips and Tricks to gazette@ssc.com

lil2cent-4595847 Let cron put backup files into your Gnome trashcan

Sat, 30 Dec 2000 01:02:24 -0500
From: Allan Peda (tl082@yahoo.com)

Cron to put bacup files in trash (if you have a gnome desktop):

I typed this up to keep my home dir clean, it assumes backup files over 1 day old should be moved to the trashcan. I run it every 5 minutes under cron

#!/bin/sh
# script to move trash files to trash can
# use cron to run this every 5 minutes

if [ x"$HOME" = x ]; then
  echo "\$HOME not defined"
  exit 1
fi

TRASHCAN=${HOME}'/.gnome-desktop/Trash/'
if [ ! -d $TRASHCAN ]; then
  echo "Need a trash can to work"
  exit 1
fi

FARGS=' -maxdepth 1 -type f -mtime +1 '
find ~ $FARGS -name '.saves-*' -exec mv {} $TRASHCAN \;
find ~ $FARGS -name  '\#*\#'   -exec mv {} $TRASHCAN \;

lil2cent-4595847 Seeing what’s changed since your tar backup

Fri, 29 Dec 2000 09:35:11 -0800
Jim Dennis (The Answer Guy)

(If you have a full tar backup of your root and /usr filesystems you can use the ‘tar df’ or ‘tar dzf’ directives to report on differences between your current files and those in your backup.

lil2cent-4595847 2cent tip: lynx mpg123 and mp3.com

Mon, 11 Dec 2000 19:58:01 -0800
From: collver@softhome.net(collver@softome.net)

mp3.com uses MIME to describe audio content to web browsers. A year or two ago, mp3.com had instructions to set up audio/mpeg and audio/mpegurl in Netscape. These MIME types no longer work because mp3.com now uses audio/x-mpeg and audio/x-mpegurl instead.

Two places to configure viewers for MIME types:

/etc/mailcap $HOME/.mailcap

I suggest editting $HOME/.mailcap as it overrides /etc/mailcap.

You might already have entries placed by Netscape. If so, they assume you only use X and they look like:

#mailcap entry added by Netscape Helper audio/x-scpls;xmms %s #mailcap entry added by Netscape Helper audio/x-mpegurl;xmms %s #mailcap entry added by Netscape Helper

audio/x-mpeg;xmms %s

If you don’t want to use xmms, delete these lines. If you want to use xmms when in X, replace ‘xmms %s’ with ‘xmms %s; test=test -n « $DISPLAY »‘

Then add:

audio/x-scpls; mpg123 -@ %s audio/x-mpegurl; mpg123 -@ %s

audio/x-mpeg; mpg123 $s

lil2cent-4595847 The Unattended Risk

Thu, 28 Dec 2000 18:57:54 -0800
allan

I realized the other day that locking your screen is next to useless if you start your linux box in text mode, performing a « startx & » to begin an X session, unless you Ctrl-Alt-F1 to your text virtual console and Ctrl-D logout, then you can Ctrl-Alt-F7 back to the X console, and lock the screen. Otherwise all a passerby need do is switch virtual terminals and use you account.

It’s sorta obvious when you think about it. Of course an unattended Linux machine is not really secure, but still, just switching virtual consoles is a little too easy.

Allan

I’ve been doing « exec startx » from non-xdm machines to save myself having to log out when I quit my X session. I think it would help with this situation too. — Don Marti

… or
startx & vlock
… to ensure that your login session will not be inadvertantly be left unlocked and unattended.

Naturally you’ll also want to look at xautolock — adding it to your .Xclients, .xsession or other windowing system start-up/configuration files as necessary.
— Jim Dennis

lil2cent-4595847 Modem Question – Easy One

Sun, 17 Dec 2000 19:59:45 EST
From: Franklyn (I3utane@aol.com)

Answer Guy,

I’ve read an response that you posted about a win modem running in linux, it wont’. But I it was posted on Feb 22, 1999. So I was hoping that came out and gave us the source and stuff. I have a US Robotics 56k Voice Win. If they haven’t, i’m out to comp usa to buy a external 3 comm (or is a internal ok?).

Be good man – thanx in advance.

Franklyn

See if http://linmodems.org or the Linmodem Mini HOWTO www.linuxdoc.org/HOWTO/Linmodem-HOWTO.html+linmodem&hl=en help.

An external modem is usually better anyway because modems generate a lot of heat, plus external modems don’t have any OS-specific idiosynchracies.

— Mike Orr

lil2cent-4595847 Monitor goes blank

Sun, 24 Dec 2000 15:29:28 +0200
From: Marius Andreiana

I’d like to turn off blanking of the monitor in X. After 10 min or so it goes blank, so I have to move the mouse from time to time when watching movies smily-4881558

I’ve tried setterm -blank 0 before starting the movie (put that in rc.local too) but no effect. setterm -blank 60 won’t work either.

setterm affects only the console. My ~/.xsession has the following command:

« ` xset dpms 1800 2400 3600 « ‘

which blanks the screen at 30 minutes, goes into power-save mode at 40 minutes, and « off » at 60 minutes. I use such a long time so it doesn’t blank out when I’m moving back and forth between the computer and the kitchen.

There are also some options in XF86Config you can try. See « man 5 XF86Config-v3 » or « man 5 XF86Config ». You have to put in a « power_saver » option; then set the BlankTime, StandbyTime, SuspendTime, and OffTime in the Screen section. These are overridden by xset.

— Mike Orr

You’re on the right track but in the wrong lane. The setterm command only affects the (virtual) terminal settings. You want the xset command.

Try the command:

     xset s off

… from any xterm. Then start your moving, kick back, and watch the show.
— Jim Dennis

lil2cent-4595847 Tips: sendmail offline

Tue, 26 Dec 2000 23:35:19 +0100 (MET)
From: Karl-Heinz Herrmann (k.-h.herrmann@fz-juelich.de)

Hi,

since I just solved a little nuisance with the newer Sendmail 8.9.3 on my system I thought it could help somebody else.

My setup: dialup connection, local sendmail is handling all outgoing e-mail and is

queuing them until online. In my ppp-start scripts sendmail will then be triggered by ‘sendmail -q’ to run the queue.

Now since the last upgrade this didn’t always work for mails sent offline but would work for mails sent while I was online. I now found out that sendmail is keeping a persistent host status directory.

sendmail.cf says: ------- # persistent host status directory

O HostStatusDirectory=.hoststat

[…]

O Timeout.hoststatus=60m ———

So if a mail was undeliverable (offline) sendmail would remember that for 60m. Only then it would ever try it again even if online and ‘sendmail -q’ is run. This status seems to be associated with each mail, so new ones go out, old ones stay.

Possible solutions:

  1. reduce the timeout to 1m or similar.
    or
  2. run ‘sendmail -bH’ as well in the ppp-start script. This will purge the host status cache.

I Hope this helps others to get a similar setup working faster then me smily-4881558

— Karl-Heinz Herrmann

lil2cent-4595847 Measure your modem connection – Bogospeed

Sat, 16 Dec 2000 11:44:11 -0500
From: Ben Okopnik (of The Answer Gang)

This one does a ‘bogo-measurement’ of the modem connection speed. Given that I’m in the process of playing with a rather shitful internal modem (bleagh!), it comes in very handy.

Several times, I’ve seen people write in to LG and ask « How can I tell how fast my modem connection is? » This little script will… well, it’ll do _something_ that will at least give you an idea. smily-4881558

In the tradition of « BogoMIPS », « bogospeed » gives you a relative value of your connection speed. This means that the numbers you see do not represent the actual speed of your connection – in my experience, they are about 25% high – but give you a general idea of what you should expect. If, for example, you normally see « 55000 bps » as your ‘bogospeed’, and you see « 33000 bps » on a given connection, you’ll know that the connection you’ve just made is about 40% slower than usual (and that you should probably try reconnecting.)

« bogospeed » normally takes about 10-15 seconds to do its stuff on a decent connection with a 56k modem, and MUCH longer on a very slow connection. To stop you from wasting your time, 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.

Ben Okopnik

#! /bin/bash
# Estimates connection speed to your ISP

# Be nice to MindSpring; put in your own ISP's name here
ISP="www.mindspring.com"

# Check if 'traceroute' is installed on the system
[ -z `which traceroute` ] && {
  echo "\"${0:2}\" requires 'traceroute' to be installed."
  exit
}

# Check if 'bing' is installed on the system
[ -z `which bing` ] && {
  echo "\"${0:2}\" requires 'bing' to be installed"
  exit
}

remote=`time traceroute -m 1 $ISP 2>/dev/null|awk '{gsub("\(|\)","");print $3 " " $4}'`
echo
echo -e "Ping time to ISP:" ${remote:15} "ms\nMeasuring speed...\n"
bing -c 1 -e 20 -S 1024 localhost ${remote:0:14} 2>&1|grep throughput

lil2cent-4595847 2-cent tip – module resource detection

Sat, 16 Dec 2000 11:19:44 -0500
From: Ben Okopnik (of The Answer Gang)

Here’s a rather nifty script I’ve crufted. Given the number of times I’ve seen people have problems with loading modules, I think it would be pretty useful.

Actually, this two-cent tip is more like a dime (hey, I worked hard on this thing! smily-4881558 Recently, I installed Debian 2.2 (potato). For various reasons – namely, the fact that I’ve got a weird soundcard and decided to play around with an internal (yechhh) PnP modem – I needed to load several modules that required various combinations of IRQs, DMAs, and I/O addresses. Having suffered with this in the past, I decided, once and for all, to resolve the mess.

If you are trying to load a module, and failing with a « Device or resource busy » error, then ‘shotgun’ is just what you need. It will try to load your module with permutations of the three supplied lists for the above values. It’s smart enough to figure out which modules don’t require any parameters, as well as warning you about modules that require other things. It will, as a last resort, try to load the module with « auto » values, and will give you good advice on what to do if everything else fails. All in all, it’s a very useful tool if you’re going to load modules for strange hardware. It will also let you know what the correct values are when it does succeed; this allows you to write them into « /etc/modules » and forget them: they’ll be auto-loaded the next time you boot.

Happy resource hunting to all! smily-4881558

Ben Okopnik

#!/bin/bash
#
# Requires bash, basename, cat, find, grep, insmod/lsmod, strings [ -z "$1" ] && { cat