1339 lines
46 KiB
HTML
1339 lines
46 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<html>
|
|
<head>
|
|
<title>More 2 Cent Tips & Tricks Issue 14</title>
|
|
</head>
|
|
|
|
<BODY BGCOLOR=#C0C0C0 TEXT=#000000 LINK=#0000FF VLINK=#0020F0
|
|
ALINK=#FF0000 BACKGROUND="../gx/spirbind.gif">
|
|
<table width=100%>
|
|
<tr><td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H4>"Linux Gazette...<I>making Linux just a little more lovable!</I>"
|
|
<IMG ALIGN=MIDDLE SRC="../gx/heart.gif"> </H4>
|
|
<P> <hr> <P>
|
|
|
|
<!-- QUICK TIPS SECTION ================================================== -->
|
|
<center>
|
|
<H1><A NAME="tips"><IMG ALIGN=MIDDLE ALT="" SRC="../gx/twocent.gif">
|
|
More 2¢ Tips!</A></H1> <BR>
|
|
Send Linux Tips and Tricks to <A HREF="mailto:gazette@ssc.com">
|
|
gazette@ssc.com
|
|
</A></center>
|
|
|
|
<p><hr><p>
|
|
<H3>Contents:</H3>
|
|
<ul>
|
|
<li><a HREF="./lg_tips14.html#quote">Backquote Warning</a>
|
|
<li><a HREF="./lg_tips14.html#bkgr">Browser Background Tip</a>
|
|
<li><a HREF="./lg_tips14.html#lower">Even Better Lowercasing of Filenames</a>
|
|
<li><a HREF="./lg_tips14.html#filter">Filtering Advertisements from WWW Tip</a>
|
|
<li><a HREF="./lg_tips14.html#less">Getting Less to View gzipped Files </a>
|
|
<li><a HREF="./lg_tips14.html#help">Help for Help on the Bash Shell</a>
|
|
<li><a HREF="./lg_tips14.html#caps">Lower Your Caps</a>
|
|
<li><a HREF="./lg_tips14.html#boot">Making Linux Boot Floppies</a>
|
|
<li><a HREF="./lg_tips14.html#xterm">More on Xterm Titlebar</a>
|
|
<li><a HREF="./lg_tips14.html#remind">Remind Tip</a>
|
|
<li><a HREF="./lg_tips14.html#scrip">Script to Call Your Editor</a>
|
|
<li><a HREF="./lg_tips14.html#web">Tip for Your Web Page</a>
|
|
<li><a HREF="./lg_tips14.html#title">Titlebar Tip</a>
|
|
<li><a HREF="./lg_tips14.html#heart">2 Bit Tip -- Heartbeat</a>
|
|
<li><a HREF="./lg_tips14.html#xdm">2 Cent Tip for xdm</a>
|
|
<li><a HREF="./lg_tips14.html#two">Two 2 Cent Tips -- syslog & X Color Depth</a>
|
|
<li><a HREF="./lg_tips14.html#depth">X Windows Depth</a>
|
|
</ul>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="quote"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Backquotes Warning
|
|
</H3>
|
|
<P>
|
|
Date: Tue, 14 Jan 1997 00:40:21 -0800
|
|
From: alan bailward <alan_bailward@mindlink.bc.ca>
|
|
<P>
|
|
In the $0.02 tip for using the script 'swaplogs' the commands :
|
|
<ty>cp /var/adm/messages /var/adm/messages.'date +%d' </ty>
|
|
uses the wrong quotes.
|
|
The backquote not the forward quote has to be used here, to make
|
|
the *output* of the command part of the filename.
|
|
<P>
|
|
alan
|
|
<blockquote> <I>
|
|
(Actually, the backquote is in the html. It's just that some Browser
|
|
fonts wont print a backquote -- in fact, mine doesn't. I'm not sure
|
|
how to get around this other than to warn people who are reading online.
|
|
If you print LG out, the quotes will be in the right direction. --Editor)
|
|
</I> </blockquote>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="bkgr"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
WWW Background Tip
|
|
</H3>
|
|
<P>
|
|
Date: Wed, 8 Jan 1997 12:23:03 -0500 (EST) <BR>
|
|
From: Kurt M. Hockenbury, <A HREF="mailto:kmh@linux.stevens-tech.edu">
|
|
kmh@linux.stevens-tech.edu</A><BR>
|
|
<P>
|
|
I noticed people complaining about backgrounds making text unreadable.
|
|
Personally, I got tired of unreadable backgrounds, as well as large
|
|
image downloads, so I turned them off. I also turned off those annoying
|
|
blink tags.
|
|
<P>
|
|
How? Add these two lines to your ~/.Xdefaults file.
|
|
<P>
|
|
Netscape*documentColorsHavePriority: False <BR>
|
|
Netscape*blinkingEnabled: False
|
|
<P>
|
|
In LG #13, Eje Gustafsson, gne@ffa.se writes:
|
|
<PRE>
|
|
>> 1.mv /var/adm/messages /var/adm/messages.prev
|
|
>> 2.touch /var/adm/messages
|
|
>> 3.kill -1 pid-of-syslogd
|
|
>>
|
|
>> This should work on a decent Unix(like) system, and I know Linux
|
|
>>is one of them.
|
|
>
|
|
>This is NOT an proper way of truncate /var/adm/messages.
|
|
>
|
|
>It is better to do:
|
|
>
|
|
> 1.cp /var/adm/messages /var/adm/messages.prev
|
|
> 2.>/var/adm/messages or cp /dev/null /var/adm/messages (both of them makes
|
|
>the file empty).
|
|
> 3.No more.
|
|
</PRE>
|
|
I'm sorry, but (at least on Linux) this is flat out _wrong_.
|
|
The first method (mv & HUP) is the correct method of truncating syslog files
|
|
(such as /var/adm/messages).
|
|
<P>
|
|
Your method looses any messages that get syslog'd between steps 1 and 2;
|
|
anything that comes in after the first cp gets overwritten when the second
|
|
cp happens.
|
|
<PRE>
|
|
>The problem is that when you remove the /var/adm/messages syslogd gets
|
|
>confused and unhappy and you have to give syslogd a HUPSIG but if you
|
|
>just sets the file length to zero without removing the file syslogd
|
|
>don't complain. And if you are really unlucky your system will go down
|
|
>because you didn't create /var/adm/messages quick enough or forgot it.
|
|
</PRE>
|
|
Not so. mv'ing /var/adm/messages doesn't bother syslogd at all, as long
|
|
as you stay on the same partition. In fact, you can 'mv
|
|
/var/adm/messages /var/adm/fish', and until syslogd is HUP'd or
|
|
otherwise restarted, it will keep logging in the file fish. Try it if
|
|
you don't believe me - it's true! That is because once syslogd has
|
|
open()d the file, it will keep writing to that file until it close()s it
|
|
- and a file in the Unix world is an inode, not a filename. (As an
|
|
aside, this is how you can have the 100% full empty partition. Even
|
|
though you unlink or rm a file, the file doesn't actually go away until
|
|
all programs that have it open close it.)
|
|
<P>
|
|
syslogd doesn't get confused at all. You can even rm /var/adm/messages, and
|
|
syslogd won't crash your system, though eventually the partition may fill
|
|
up with syslog messages you can't easily read since there isn't a filename
|
|
associated with the log file anymore.
|
|
<P>
|
|
Kurt Hockenbury, Distributed Systems Administrator <BR>
|
|
Stevens Institute of Technology
|
|
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="lower"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Even Better Lowercasing of Filenames</H3>
|
|
<P>
|
|
Date: Sun, 5 Jan 1997 19:17:16 -0800 (PST)
|
|
From: Greg Badros, <A HREF="mailto:gjb@cs.washington.edu">
|
|
gjb@cs.washington.edu </A>
|
|
<P>
|
|
It's even easier with zsh (3.0.x) to convert filenames to all-lowercase:
|
|
<PRE>
|
|
for i in *(.); mv $i ${i:l}
|
|
</PRE>
|
|
The *(.) uses a modifier on the wildcard to mean "only regular files"
|
|
(i.e., not directories). And the ${i:l} converts the variable to
|
|
lowercase, so we don't have to use tr.
|
|
<P>
|
|
This is not only shorter to type, but doesn't exec multiple programs (test
|
|
+ mv + tr) for each file, and looks at fewer files since the shell
|
|
implicitly does the first test.
|
|
<P>
|
|
Greg
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="filter"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Filtering Advertisements from Web Pages using WebFilter
|
|
</H3>
|
|
Date: Thu, 16 Jan 97 20:28:50 PST <BR>
|
|
From: Axel Boldt, <A HREF="mailto:boldt@cardinal.math.ucsb.edu">
|
|
boldt@cardinal.math.ucsb.edu </A>
|
|
<P>
|
|
Hi,
|
|
In last month's Gazette, David Rudder wrote an article about <a
|
|
href="../issue13/filter.html">how to filter
|
|
advertisements from web pages using IPFWADM</a>, the idea being that
|
|
many ads come from the same site and it is easy to configure a Linux
|
|
firewall to refuse all connections from such a site.<p>
|
|
|
|
This approach has two disadvantages: you have to be root in order to
|
|
use the IPFWADM tool, and it allows you only to block entire sites.
|
|
Very often, you want to filter out only a specific ad residing on a
|
|
site, without blocking the rest of that site's material. Moreover,
|
|
different users of the Linux box might have different tastes when it
|
|
comes to ads.<p>
|
|
|
|
I believe that my tool WebFilter a.k.a. NoShit addresses these issues
|
|
and is better suited for filtering ads from specific web sites. The
|
|
idea is the following: the user runs WebFilter as a personal filtering
|
|
proxy server, and the browser contacts this proxy whenever it wants to
|
|
fetch a web document. The proxy then actually goes out and downloads
|
|
the page, checks whether any filterscripts apply to this page, and if
|
|
yes, pipes it through those scripts and returns the output to the
|
|
browser. The mapping between URL and filterscript has to be provided
|
|
by the user in advance. A filterscript can be an arbitrary program
|
|
that reads the original document from standard input and produces the
|
|
filtered version on standard output. In practice, filterscripts are
|
|
most often short sed, awk, or perl scripts.<p>
|
|
|
|
If you often use sites such as Yahoo or Infoseek, you can easily write
|
|
filterscripts that excise the ads from their pages. This saves time,
|
|
money, and bandwidth.<p>
|
|
|
|
More information about WebFilter can be gotten from its <a
|
|
href="http://www.math.ucsb.edu/~boldt/NoShit/">homepage</a>. There
|
|
you'll also find links to other programs implementing the same idea.<p>
|
|
|
|
Have fun,<br>
|
|
Axel
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="less"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Getting less to View gzipped Files
|
|
</H3>
|
|
Date: 09 Jan 1997 20:18:58 -0600 <BR>
|
|
From: Alan Shutko, <A HREF="mailto:ats@wydo125.wustl.edu">
|
|
ats@wydo125.wustl.edu </A>
|
|
<P>
|
|
A little known ability of less is the ability to define filters when
|
|
it opens and closes files. This excerpt from the man page deserves
|
|
broader attention, since it can easily be extended to other types.
|
|
<P>
|
|
For example, on many Unix systems, these two scripts will
|
|
allow you to keep files in compressed format, but still
|
|
let less view them directly:
|
|
<PRE>
|
|
lessopen.sh:
|
|
#! /bin/sh
|
|
case "$1" in
|
|
*.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null
|
|
if [ -s /tmp/less.$$ ]; then
|
|
echo /tmp/less.$$
|
|
else
|
|
rm -f /tmp/less.$$
|
|
fi
|
|
;;
|
|
|
|
Version 321: 18 Jul 96 16
|
|
|
|
esac
|
|
|
|
lessclose.sh:
|
|
#! /bin/sh
|
|
rm $2
|
|
</PRE>
|
|
To use these scripts, put them both where they can be exe-
|
|
cuted and set <ty> LESSOPEN="lessopen.sh %s"</ty>, and
|
|
<ty>LESSCLOSE="lessclose.sh %s %s"</ty>. More complex LESSOPEN and
|
|
LESSCLOSE scripts may be written to accept other types of
|
|
compressed files, and so on.
|
|
<P>
|
|
Alan Shutko
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="help"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Help for Help on the Bash Shell
|
|
</H3>
|
|
Date: Tue, 14 Jan 1997 15:36:50 +0100 (NFT) <BR>
|
|
From: <A HREF="mailto:fk5a005@math.uni-hamburg.de">
|
|
mailto:fk5a005@math.uni-hamburg.de </A>
|
|
<P>
|
|
you did hear about help for the bash.
|
|
if you invoke <ty>help for</ty>
|
|
then you will get some help about for.
|
|
<P>
|
|
Okay, you know that one.
|
|
But did you know you can see all the helps at once?
|
|
I did not know it.
|
|
Then I tried
|
|
<ty>help "$*"</ty> and what happend was: every help was shown!
|
|
Of course too much for one screen.
|
|
so I piped it to less: <ty>help "$*" |less</ty> is quite good.
|
|
But then I thought about having a search command with less.
|
|
possible? yes, just do a less -p word file to see it.
|
|
<P>
|
|
So I put everything together and like I do often I created an alias:
|
|
<PRE>
|
|
alias helpall="help '$*' | less -p "
|
|
</PRE>
|
|
and tried it: beautiful, I might not need man bash all the times.
|
|
Try it yourself.
|
|
<P>
|
|
Perhaps try <ty>helpall " let "</ty> to see a result.
|
|
<P>
|
|
Have a nice and bright Linux-year!
|
|
<P>
|
|
Matthias
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="caps"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Lower Your CAPS
|
|
</H3>
|
|
Date: Sat, 25 Jan 1997 20:44:42 -0800 (PST) <BR>
|
|
From: Peat Bakke, <A HREF="mailto:pb@europa.com">pb@europa.com</A>
|
|
<P>
|
|
One of those little things that gets to me is unzipping DOS pkzipped
|
|
files. All of the filenames are in all caps. I'm not sure why it bugs me,
|
|
but it does. Anyhow, here's a quick script that I've found useful to convert
|
|
all the caps in a directory into lower case (rather nice when you've got one
|
|
of those big, 200 file zips):
|
|
<PRE>
|
|
#!/bin/tcsh
|
|
foreach i (*)
|
|
mv $1 `echo $1 | tr '[A-Z]' '[a-z]'`
|
|
</PRE>
|
|
A word to the wise -- this lowers ALL caps, so be careful with those
|
|
Makefiles and such.
|
|
<P>
|
|
-Peat
|
|
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="boot"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Making Linux Boot Floppies
|
|
</H3>
|
|
Date: Sun, 5 Jan 1997 18:40:49 -0800 (PST) <BR>
|
|
From: Andy Kahn, <A HREF="mailto:kahn@vivian.cs.ucla.edu">
|
|
kahn@vivian.cs.ucla.edu </A><BR>
|
|
<P>
|
|
After reading Bill Duncan's excellent article in
|
|
<a href="../issue13/floppies.html">
|
|
issue #13</a>
|
|
on using and managing floppies in Linux, I figured I'd
|
|
toss in a 2-cent tip.
|
|
<p>
|
|
Here is a script I use to make emergency boot floppies
|
|
on my system (kernel v2.0.27). The need arose when I
|
|
installed RedHat 4.0 for the first time and noticed
|
|
that the installation procedure doesn't automatically
|
|
prompt you to create boot floppies (Slackware does, and
|
|
chances are that RedHat will also in the next version).
|
|
|
|
<p>
|
|
|
|
<pre>
|
|
#!/bin/csh -f
|
|
#
|
|
# makebootfloppy v0.2
|
|
#
|
|
# DESCRIPTION:
|
|
# User friendly script (with lots of verbose messages) used to make
|
|
# Linux boot floppies, using the 2.x kernels.
|
|
#
|
|
# Formats, creates the file system, mounts the floppy, installs the Linux
|
|
# kernel, installs LILO, umounts floppy, and cleans up.
|
|
#
|
|
# (Webmaster's note: Be sure to replace the "^C" in the line below
|
|
# with a real control-C character! Sorry for the inconvenience ... )
|
|
#
|
|
stty intr ^C
|
|
set PATH=(/usr/sbin /sbin /bin /usr/bin)
|
|
|
|
# the generic floppy device (usually auto-detected)
|
|
set GENFLOPPY=/dev/fd0
|
|
|
|
# the low-level floppy device, used with fdformat. this might be obsoleted
|
|
# on your system
|
|
set LLFLOPPY=/dev/fd0H1440
|
|
|
|
# a temporary mount point for your floppy. make sure it has enough space
|
|
# to copy the kernel into
|
|
set MOUNTPOINT=/tmp/floppy
|
|
|
|
# boot
|
|
set BOOT=/boot/boot.b
|
|
set KERNEL=/boot/vmlinuz
|
|
|
|
# LILO label
|
|
set LABEL=linux
|
|
|
|
|
|
# here we go!
|
|
#############
|
|
echo -n Insert a blank floppy into the drive and hit return...
|
|
set FOO=$<
|
|
|
|
# Low-level formatting the floppy...
|
|
fdformat $LLFLOPPY
|
|
|
|
# Making file system on floppy...
|
|
mke2fs -c $GENFLOPPY
|
|
|
|
# Mount the floppy
|
|
mkdir $MOUNTPOINT >& /dev/null
|
|
mount $GENFLOPPY $MOUNTPOINT
|
|
|
|
# Copy the kernel to the floppy
|
|
cp $BOOT $MOUNTPOINT
|
|
cp $KERNEL $MOUNTPOINT
|
|
|
|
# Install lilo
|
|
echo image=$MOUNTPOINT/`basename $KERNEL` label=$LABEL | \
|
|
lilo -C - -b $GENFLOPPY -i $MOUNTPOINT/boot.b -c -m $MOUNTPOINT/map
|
|
|
|
sync
|
|
|
|
# Unmount floppy
|
|
umount $MOUNTPOINT
|
|
|
|
# Deleting temporary mount point
|
|
rm -rf $MOUNTPOINT
|
|
|
|
echo All done.
|
|
</pre>
|
|
|
|
<p> <hr> <p>
|
|
There's currently no error handling, so if one
|
|
command fails, the remaining commands will fail as well.
|
|
Other than that, feel free to modify and use it as you
|
|
like. If you have suggestions on better ways to do
|
|
something, I'd love to hear them.<br>
|
|
--Andy, kahn@cs.ucla.edu <BR>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="xterm"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
More on Xterm Titlebar Tip
|
|
</H3>
|
|
Date: Wed, 15 Jan 1997 23:33:34 -0700 (MST) <BR>
|
|
From: Michael J. Hammel, <A HREF="mailto:mjhammel@csn.net">
|
|
mjhammel@csn.net </A>
|
|
<P>
|
|
I got a lot of email about my tip, most confused by the use of
|
|
escape/control characters in the script. Here is my response.
|
|
<PRE>
|
|
> > Date: Sat, 21 Dec 1996 15:18:01 -0600
|
|
> > From: Roger Booth <Roger_Booth@crow.bmc.com>
|
|
> > To: Linux Journal Editor
|
|
> >
|
|
> > The Jan97 Issue 33 of Linux Journal contained the "Linux Gazette Two Cent Tips".
|
|
> > I was interested in the tip "X Term Titlebar Function". Although
|
|
> > the text of the tip stated that the tip would work in ksh-based
|
|
> > systems, I could not get it to work as shown. I think there are
|
|
> > three problems. First, I think there are a few transcription
|
|
> > errors in the script. Second, I believe the author is using
|
|
</PRE>
|
|
I don't think there were transcription problems. I'm pretty sure
|
|
it was the way I sent it, however....
|
|
<PRE>
|
|
> > embedded control characters and it was not obvious to me which
|
|
> > character sequences are representations of control characters
|
|
> > and which characters should be typed verbatim. Third, the
|
|
</PRE>
|
|
Yes, there were control and escape characters in the file.
|
|
This was a problem and many people wrote me to ask about it.
|
|
In the following lines:
|
|
<PRE>
|
|
ilabel () { echo -n "^[]1;$*^G"; }
|
|
label () { echo -n "^[]2;$*^G"; }
|
|
</PRE>
|
|
the characters "^[" are an escape character and the characters "^G" are a
|
|
CONTROL-G character. In order to add these to your file (when you type it
|
|
in by hand) using vi you would type:
|
|
<P>
|
|
<ty> ^VESC</ty> - which means CTRL-SHIFT-V followed by the ESCAPE key
|
|
<P>
|
|
and
|
|
<P>
|
|
<ty> ^V^G</ty> - which means CTRL-SHIFT-V followed by CTRL-SHIFT-G
|
|
<P>
|
|
Note that in *this* email I didn't actually include the control or escape
|
|
characters - I simply used their ASCII equivalents. Hopefully this isn't
|
|
too confusing.
|
|
<PRE>
|
|
> > author uses a command-line option to the echo command which
|
|
> > is not available on all Unix platforms.
|
|
</PRE>
|
|
This is also a problem. See below.
|
|
<PRE>
|
|
> > I finally used the following script:
|
|
> >
|
|
> > if [ ${SHELL##/*/} = "ksh" ] ; then
|
|
> > if [[ $TERM = x"term" ]] ; then
|
|
> > HOSTNAME=`uname -n`
|
|
> > label () { echo "\\033]2;$*\\007\\c"; }
|
|
> > alias stripe='label $LOGNAME on $HOSTNAME - ${PWD#$HOME/}'
|
|
> > cds () { "cd" $*; eval stripe; }
|
|
> > alias cd=cds
|
|
> > eval stripe
|
|
> > fi
|
|
> > fi
|
|
> > I don't use vi, so I left out that functionality.
|
|
</PRE>
|
|
I tried this and various similar responses that were mailed directly to me.
|
|
It should work using the octal versions of the escape sequences, but I
|
|
couldn't get it to work. My problem is that I use the label() function
|
|
from the command line at times to simply set the title bar to some
|
|
arbitrary value and using the octal sequences didn't seem to work for me.
|
|
I'm not sure why, however. I do believe that, sometime in the distant
|
|
past, I too used octal sequences to set the xterm title bar. I've long
|
|
forgotten why I switched.
|
|
<PRE>
|
|
> > The functional changes I made are all in the arguments to the
|
|
> > echo command. The changes are to use \\033 rather than what
|
|
> > was shown in the original tip as ^[, to use \\007 rather than
|
|
> > ^G, and to terminate the string with \\c rather than use the
|
|
> > option -n.
|
|
</PRE>
|
|
All of these should work just fine in ksh. Your observation that not all
|
|
shells accept "echo -n" is correct. I often have to check which works and
|
|
then manually set the echo line to either use "-n" or to print a \c. One
|
|
or the other will always work, depending on if the echo is a shell
|
|
builtin or an actual Unix command.
|
|
<PRE>
|
|
> > On AIX 4.1, the command "echo -n hi" echoes "-n hi"; in other
|
|
> > words, -n is not a portable command-line option to the echo
|
|
> > command. I tested the above script on AIX 3.2, AIX 4.1,
|
|
> > HPUX 9.0, HPUX 10.0, Solaris 2.4 and Solaris 2.5. I'm still
|
|
> > trying to get Linux and my Wintel box mutually configured,
|
|
> > so I haven't tested it on Linux.
|
|
</PRE>
|
|
I don't use X on the AIX or HPUX boxes at work. I just rlogin from my Sun
|
|
boxes. However, both Solaris and Linux should work with the -n option if
|
|
you're using the echo shell builtin. If not, the \c will probably be
|
|
required. On my Linux box I type
|
|
<PRE>
|
|
bash% type echo
|
|
</PRE>
|
|
which reports
|
|
<PRE>
|
|
echo is a shell builtin
|
|
</PRE>
|
|
so I know which one I'm using. Knowing this you can provide alternatives
|
|
within your .bashrc or .kshrc to determine which version of the echo line
|
|
to use. This is true of any Unix platform on which you use ksh or bash
|
|
(I believe).
|
|
<PRE>
|
|
> > I have noticed a problem with this script. I use the rlogin
|
|
> > command to log in to a remote box. When I exit from the
|
|
> > remote box, the caption is not updated, and still shows the
|
|
> > hostname and path that was valid just before I exited. I tried
|
|
> > adding
|
|
> >
|
|
> > exits () { "exit" $*; eval stripe; }
|
|
> > alias exit=exits
|
|
> >
|
|
> > and
|
|
> >
|
|
> > rlogins () { "rlogin" $*; eval stripe; }
|
|
> > alias rlogin=rlogins
|
|
> >
|
|
> > Neither addition updated the caption to the host/path
|
|
> > returned to. Any suggestions?
|
|
</PRE>
|
|
Add this right after the alias for cd in the original script:
|
|
<PRE>
|
|
rlogins () { "rlogin" $*; cds . }
|
|
alias rlogin=rlogins
|
|
</PRE>
|
|
Its a hack, but it works. You have to use "cds" instead of the alias "cd"
|
|
or else the real cd gets used and the title bar won't change. In case
|
|
anyone is wondering, the reason you enclose "rlogin" (or "cd" or "vi") in
|
|
double quotes in this script is so the function rlogins() will run the real
|
|
rlogin and not get stuck recursively calling itself. Neat, eh?
|
|
<P>
|
|
Boy, this stuff could get confusing fast. Maybe it wasn't such a good tip
|
|
after all. <g>
|
|
<P>
|
|
Michael J. Hammel
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="remind"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Remind Tip
|
|
</H3>
|
|
<P>
|
|
Date: Mon, 20 Jan 97 15:42:04 PST <BR>
|
|
From: <A HREF="mailto:jmy@gim.net">jmy@gim.net </A>
|
|
<P>
|
|
This is a nice little script wich I have made, it places reminders to
|
|
~/.tcshrc or whatever. I think it's very useful. To use it first place at
|
|
THE END OF ~/.tcshrc:
|
|
<PRE>
|
|
\echo
|
|
echo "--------------------( R E M I N D E R S )--------------------"
|
|
echo "-------------------------------------------------------------";\echo
|
|
</PRE>
|
|
Then use this script:
|
|
<PRE>
|
|
------------------------------c-u-t--h-e-r-e-------------------------------
|
|
#!/bin/tcsh
|
|
# Nice little scipt that places reminders to the end of ~/.tcshrc or
|
|
whatever.
|
|
# Made by jmy@gim.net email if you like it!
|
|
|
|
echo Remind 1.0 by jmy@gim.net
|
|
if ($#argv == 0) then
|
|
echo Use like \'remind \<option\> \<Reminder message\>\'
|
|
echo Option is \'a\' for add , \'u\' for undo and \'r\' for remove, pretty
|
|
easy
|
|
huh..:\)
|
|
\echo
|
|
echo NOTE: IF YOU REMOVED A LINE YOU DIDN\'T MEAN TO REMOVE, USE UNDO\!
|
|
\echo
|
|
exit 666
|
|
endif
|
|
if ($argv[1] == a) then
|
|
cat ~/.tcshrc | awk '\!/-------\";\\echo/ { print }' >! /tmp/remind.$user
|
|
echo echo $argv[2-] >> /tmp/remind.$user
|
|
echo 'echo "-------------------------------------------------------------";\echo'
|
|
>> /tmp/remind.$user
|
|
cp ~/.tcshrc ~/.tcshrc.remind
|
|
rm -f ~/.tcshrc
|
|
mv /tmp/remind.$user ~/.tcshrc
|
|
echo Added reminder: $argv[2-]
|
|
else if ($argv[1] == r) then
|
|
cat ~/.tcshrc | grep -v "echo $argv[2-]" >! /tmp/remind.$user
|
|
cp ~/.tcshrc ~/.tcshrc.remind
|
|
rm -f ~/.tcshrc
|
|
mv /tmp/remind.$user ~/.tcshrc
|
|
echo Removed Reminders:
|
|
diff ~/.tcshrc ~/.tcshrc.remind | awk '$2 ~ /echo/ { print$3,$4,$5,$6,$7,$8,$9,
|
|
$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25 }'
|
|
else if ($argv[1] == u) then
|
|
if (-e ~/.tcshrc.remind) then
|
|
mv ~/.tcshrc ~/.tcshrc.remtemp
|
|
mv ~/.tcshrc.remind ~/.tcshrc
|
|
mv ~/.tcshrc.remtemp ~/.tcshrc.remind
|
|
echo Undo completed
|
|
else
|
|
echo No undo file was found \(~/.tcshrc\)
|
|
endif
|
|
else
|
|
echo Error: invalid argument\(s\) run it with no argument for a short help
|
|
\echo
|
|
exit 666
|
|
endif
|
|
\echo
|
|
---------------------c-u-t--h-e-r-e--a-l-s-o------------------------------
|
|
</PRE>
|
|
Dont forget to do a 'chmod a+x remind'
|
|
And NEVER place any new lines after the lines you placed in ~/.tcshrc
|
|
If you wan't to use it with some other shell it should just be like
|
|
changing the paths in the script. And yes, it maybe should have been alot
|
|
easier to put the reminders in a separat file, but i like this solution
|
|
i'ts alot cooler...and maybe it can show someone how awk works.
|
|
|
|
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="scrip"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Script to Call Your Editor
|
|
</H3>
|
|
Date: Thu, 16 Jan 97 15:21:34 PST <BR>
|
|
From: Gary Chambers, <A HREF="mailto:geecee@gwi.net">geecee@gwi.net</A>
|
|
<P>
|
|
I just found the Linux Gazette... Thankfully! It has truly made using
|
|
Linux more fun.
|
|
<P>
|
|
I use the Linux version of Marko Macek's FTE editor. Since it is
|
|
comprised of a separate X and console version, I began to get
|
|
frustrated with having to manually specify a default editor. Now,
|
|
wherever I can specify it (e.g. Pine), I use my edit script. It also
|
|
provides similar functionality at the command line.
|
|
<P>
|
|
I'm new to Linux, so there may be better ways of doing this. I
|
|
submitted this for inclusion in your 2-cent tips (my favorite section).
|
|
<PRE>
|
|
#!/bin/bash
|
|
|
|
# Determine whether we're in X Windows and call the proper editor
|
|
#
|
|
|
|
if [ "$WINDOWID" = "" ]; then
|
|
fte $1 $2 $3 $4 $5
|
|
else
|
|
xfte $1 $2 $3 $4 $5
|
|
fi
|
|
</PRE>
|
|
GeeCee, Gary Chambers
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="web"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Tip for Your Web Page
|
|
</H3>
|
|
Date: Fri, 3 Jan 1997 17:26:14 -0500 (EST) <BR>
|
|
From: Ben Boule, <A HREF="mailto:bouleb@rpi.edu">bouleb@rpi.edu</A><BR>
|
|
<P>
|
|
One cool tip that I have found useful is the following.
|
|
If you are running your web page on your own machine or have the
|
|
directory on NFS, put the following in your .profile :
|
|
<P>
|
|
cp ~/.netscape/bookmarks.html ~/public_html/bookmarks.html <BR>
|
|
cp ~/lynx_bookmarks.html ~/public_html/bookmarks2.html
|
|
<P>
|
|
Change for different browsers and server setups.
|
|
<P>
|
|
Then you can link them on your web page, and they get updated every time
|
|
you log in, start a new xterm, etc...
|
|
<P>
|
|
Of course, this assumes you don't care about other people looking at your
|
|
bookmarks.
|
|
<P>
|
|
Later,<BR>
|
|
Ben Boule
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="title"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Re: Titlebar Tip
|
|
</H3>
|
|
Date: Mon, 20 Jan 1997 18:40:38 +0200 (SAT)<BR>
|
|
From: Christopher Gordon, <A HREF="mailto:chris@bayes.agric.za">
|
|
chris@bayes.agric.za </A>
|
|
<P>
|
|
Roger Booth sent in a corrected version of the Titlebar script. I found that
|
|
in order to get this working on a Slackware distribution of Linux, using
|
|
the bash shell, further modifications were neccesary. The control characters
|
|
need one \ as opposed to \\. The "echo" command required an -e switch. The
|
|
"if" statement only needed one [] not two. Finally, the script needed to
|
|
check if "bash" was running or not. I also added a command to simplify the
|
|
prompt. Here is the corrected script. It can be run using the source command.
|
|
<PRE>
|
|
if [ ${SHELL##/*/} = "bash" ] ; then
|
|
if [ $TERM = x"term" ] ; then
|
|
HOSTNAME=`uname -n`
|
|
label () { echo -e "\033]2;$*\007\c"; }
|
|
alias stripe='label $LOGNAME on $HOSTNAME - ${PWD#$HOME/}'
|
|
cds () { "cd" $*; eval stripe; }
|
|
alias cd=cds
|
|
eval stripe
|
|
export PS1='\$ '
|
|
fi
|
|
fi
|
|
</PRE>
|
|
Standard disclaimers apply.
|
|
<P>
|
|
Regards, <BR>
|
|
Christopher Gordon, <BR>
|
|
Remote Sensing, Inst. for Soil, Climate and Water <BR>
|
|
Pretoria, South Africa
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="heart"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Two Bit Tip -- Heartbeat
|
|
</H3>
|
|
Date: Wed, 22 Jan 1997 22:29:06 -0800 (PST) <BR>
|
|
From: Kragen Sittler, <A HREF="mailto:kragen@netcom.com">kragen@netcom.com</A>
|
|
<PRE><H5>
|
|
#!/bin/sh
|
|
# This is a shell archive (produced by GNU sharutils 4.1).
|
|
# To extract the files from this archive, save it to some FILE, remove
|
|
# everything before the `!/bin/sh' line above, then type `sh FILE'.
|
|
#
|
|
# Made on 1997-01-22 22:11 PST by <heartbeat@gentle>.
|
|
# Source directory was `/usr/local/heartbeat'.
|
|
#
|
|
# Existing files will *not* be overwritten unless `-c' is specified.
|
|
#
|
|
# This shar contains:
|
|
# length mode name
|
|
# ------ ---------- ------------------------------------------
|
|
# 2222 -rw-r--r-- README
|
|
# 102 -rw-r--r-- crontab
|
|
# 371 -rwxr-xr-x heartbeat
|
|
# 142 -r-xr-xr-x rc.heartbeat
|
|
# 1045 -rwxr-xr-x update.sessionid
|
|
#
|
|
touch -am 1231235999 $$.touch >/dev/null 2>&1
|
|
if test ! -f 1231235999 && test -f $$.touch; then
|
|
shar_touch=touch
|
|
else
|
|
shar_touch=:
|
|
echo
|
|
echo 'WARNING: not restoring timestamps. Consider getting and'
|
|
echo "installing GNU \`touch', distributed in GNU File Utilities..."
|
|
echo
|
|
fi
|
|
rm -f 1231235999 $$.touch
|
|
#
|
|
# ============= README ==============
|
|
if test -f 'README' && test X"$1" != X"-c"; then
|
|
echo 'x - skipping README (file already exists)'
|
|
else
|
|
echo 'x - extracting README (text)'
|
|
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
|
|
Heartbeat package
|
|
X
|
|
My computer seems to crash often -- about once every ten days. I've been
|
|
wanting to know when this happens, but since the computer is busily crashing,
|
|
it doesn't have time to tell me. (I suspect this happens because of power
|
|
outages.)
|
|
X
|
|
So I wrote a simple heartbeat package, which would keep a record in the
|
|
filesystem when it was alive. That way, I could look at this record when
|
|
the machine crashed and tell when and how long it had crashed.
|
|
X
|
|
So I wrote a few scripts and created a new user. I named the heartbeat user
|
|
'heartbeat'. (I know it's not really kosher to have a nine-letter username,
|
|
but the only thing that has problems with it so far is ls.)
|
|
X
|
|
heartbeat is the first script; it updates a file in /var/log/heartbeat.
|
|
X
|
|
Here's the meat of heartbeat.
|
|
X
|
|
X #!/bin/sh
|
|
X touch /var/log/heartbeat/"`cat /var/run/heartbeat.sid`"
|
|
X
|
|
/var/log/heartbeat should be writable and executable by the heartbeat user;
|
|
you may want to use root. heartbeat gets run once a minute on my
|
|
system, from the heartbeat's crontab:
|
|
X
|
|
* * * * * /usr/local/heartbeat/heartbeat
|
|
X
|
|
(For some reason, my crond does not like whitespace before crontab entries.)
|
|
X
|
|
The name of the file it updates is taken from /var/run/heartbeat.sid. (I'm
|
|
not sure /var/run is really an appropriate place to put this, but I couldn't
|
|
find a better place.) This file should be readable and writable by the
|
|
heartbeat user.
|
|
X
|
|
heartbeat.sid is updated at boot time by a Perl script called update.sessionid.
|
|
update.sessionid also puts some information in the file that heartbeat updates.
|
|
X
|
|
I run update.sessionid (as the heartbeat user) from /etc/rc.d/rc.M, just before
|
|
cron is started.
|
|
X
|
|
Here's the section from my rc.M:
|
|
X
|
|
X....
|
|
#
|
|
# Update heartbeat sessionid.
|
|
# This helps us find out when there was a crash.
|
|
[ -x /etc/rc.d/rc.heartbeat ] && /etc/rc.d/rc.heartbeat
|
|
X
|
|
# Start crond (Dillon's crond):
|
|
X....
|
|
X
|
|
and here's /etc/rc.d/rc.heartbeat:
|
|
X
|
|
#!/bin/sh
|
|
# Update the heartbeat sessionid.
|
|
# This should be done before starting cron.
|
|
su heartbeat -c /usr/local/heartbeat/update.sessionid
|
|
X
|
|
Now, when I want to know when the machine crashed, I can look in
|
|
/var/log/heartbeat for the times of system shutdowns -- planned or
|
|
otherwise.
|
|
SHAR_EOF
|
|
$shar_touch -am 0122221197 'README' &&
|
|
chmod 0644 'README' ||
|
|
echo 'restore of README failed'
|
|
shar_count="`wc -c < 'README'`"
|
|
test 2222 -eq "$shar_count" ||
|
|
echo "README: original size 2222, current size $shar_count"
|
|
fi
|
|
# ============= crontab ==============
|
|
if test -f 'crontab' && test X"$1" != X"-c"; then
|
|
echo 'x - skipping crontab (file already exists)'
|
|
else
|
|
echo 'x - extracting crontab (text)'
|
|
sed 's/^X//' << 'SHAR_EOF' > 'crontab' &&
|
|
# MIN HOUR DAY MONTH DAYOFWEEK COMMAND
|
|
* * * * * /usr/local/heartbeat/heartbeat
|
|
SHAR_EOF
|
|
$shar_touch -am 0122221197 'crontab' &&
|
|
chmod 0644 'crontab' ||
|
|
echo 'restore of crontab failed'
|
|
shar_count="`wc -c < 'crontab'`"
|
|
test 102 -eq "$shar_count" ||
|
|
echo "crontab: original size 102, current size $shar_count"
|
|
fi
|
|
# ============= heartbeat ==============
|
|
if test -f 'heartbeat' && test X"$1" != X"-c"; then
|
|
echo 'x - skipping heartbeat (file already exists)'
|
|
else
|
|
echo 'x - extracting heartbeat (text)'
|
|
sed 's/^X//' << 'SHAR_EOF' > 'heartbeat' &&
|
|
#!/bin/sh
|
|
# script to continually update a file's timestamp, except when the machine
|
|
# is down
|
|
#
|
|
# This should be put in a crontab to be run every minute, or five minutes,
|
|
# or whatever.
|
|
#
|
|
# /var/run/heartbeat.sid contains a sessionid that is incremented at each
|
|
# bootup, and is suitable for use as a filename.
|
|
X
|
|
touch /var/log/heartbeat/"`cat /var/run/heartbeat.sid`"
|
|
SHAR_EOF
|
|
$shar_touch -am 0122210097 'heartbeat' &&
|
|
chmod 0755 'heartbeat' ||
|
|
echo 'restore of heartbeat failed'
|
|
shar_count="`wc -c < 'heartbeat'`"
|
|
test 371 -eq "$shar_count" ||
|
|
echo "heartbeat: original size 371, current size $shar_count"
|
|
fi
|
|
# ============= rc.heartbeat ==============
|
|
if test -f 'rc.heartbeat' && test X"$1" != X"-c"; then
|
|
echo 'x - skipping rc.heartbeat (file already exists)'
|
|
else
|
|
echo 'x - extracting rc.heartbeat (text)'
|
|
sed 's/^X//' << 'SHAR_EOF' > 'rc.heartbeat' &&
|
|
#!/bin/sh
|
|
# Update the heartbeat sessionid.
|
|
# This should be done before starting cron.
|
|
su heartbeat -c /usr/local/heartbeat/update.sessionid
|
|
SHAR_EOF
|
|
$shar_touch -am 0122221197 'rc.heartbeat' &&
|
|
chmod 0555 'rc.heartbeat' ||
|
|
echo 'restore of rc.heartbeat failed'
|
|
shar_count="`wc -c < 'rc.heartbeat'`"
|
|
test 142 -eq "$shar_count" ||
|
|
echo "rc.heartbeat: original size 142, current size $shar_count"
|
|
fi
|
|
# ============= update.sessionid ==============
|
|
if test -f 'update.sessionid' && test X"$1" != X"-c"; then
|
|
echo 'x - skipping update.sessionid (file already exists)'
|
|
else
|
|
echo 'x - extracting update.sessionid (text)'
|
|
sed 's/^X//' << 'SHAR_EOF' > 'update.sessionid' &&
|
|
#!/usr/bin/perl
|
|
# Update sessionid for heartbeat, creating new sessionid file.
|
|
# This should be run at boot time.
|
|
X
|
|
my $sessionidfile = "/var/run/heartbeat.sid";
|
|
my $heartbeatdir = "/var/log/heartbeat";
|
|
X
|
|
open SESSIONIDFILE, $sessionidfile or
|
|
X die "Couldn't open <$sessionidfile> for read";
|
|
X
|
|
my $sessionid = <SESSIONIDFILE>; close SESSIONIDFILE;
|
|
chomp $sessionid;
|
|
X
|
|
if ($sessionid !~ /^[a-zA-Z]*[0-9]{4,}$/) { $sessionid = "boot0000"; }
|
|
X
|
|
$sessionid ++;
|
|
X
|
|
open SESSIONIDFILE, ">$sessionidfile" or
|
|
X die "Couldn't open <$sessionidfile> for write";
|
|
X
|
|
print SESSIONIDFILE "$sessionid\n";
|
|
close SESSIONIDFILE;
|
|
X
|
|
my $heartbeatfile = "$heartbeatdir/$sessionid";
|
|
X
|
|
open HEARTBEATFILE, ">$heartbeatfile" or
|
|
X die "Couldn't open <$heartbeatfile> for write";
|
|
X
|
|
my $message = <<end_of_message
|
|
Heartbeat file created. System status:
|
|
end_of_message
|
|
;
|
|
X
|
|
my $uptime = `/usr/bin/uptime`;
|
|
my $date = `/bin/date`;
|
|
X
|
|
print HEARTBEATFILE $message, $date, $uptime or
|
|
X die "Write to <$heartbeatfile> failed after open; fs full? stopped";
|
|
X
|
|
close HEARTBEATFILE;
|
|
X
|
|
Xexit 0;
|
|
SHAR_EOF
|
|
$shar_touch -am 0122211997 'update.sessionid' &&
|
|
chmod 0755 'update.sessionid' ||
|
|
echo 'restore of update.sessionid failed'
|
|
shar_count="`wc -c < 'update.sessionid'`"
|
|
test 1045 -eq "$shar_count" ||
|
|
echo "update.sessionid: original size 1045, current size $shar_count"
|
|
fi
|
|
exit 0
|
|
</H5> </PRE>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="xdm"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
2 Cent Tip for xdm
|
|
</H3>
|
|
Date: Sun, 5 Jan 1997 21:28:02 -0600 (CST) <BR>
|
|
From: Andrew Dyer, <A HREF="mailto:adyer@Mcs.Net">adyer@Mcs.Net</A>
|
|
<P>
|
|
here are several ways you can dress up an xdm login screen:
|
|
<ol>
|
|
<li> use the 'Xbanner' program available on sunsite
|
|
<li> run a program like xearth or xfishtank that writes to
|
|
the X login screen background
|
|
<li> use a static image display program like 'xv' to put up a
|
|
simple bitmap
|
|
</ol>
|
|
I use xv to put up an image - to do this add a line like the following to
|
|
the file /usr/X11R6/lib/X11/xdm/Xsetup_0 (at least that's where is is in
|
|
my system (Caldera)):
|
|
<P>
|
|
/usr/X11R6/bin/xv -rmode 1 -nc 64 -quit /home/adyer/pics/arcade.bmp
|
|
<P>
|
|
This line will run 'xv' to put the image file at the end of the command
|
|
line onto the background window in 'root tiled' mode, dithers the image to
|
|
only use 64 colors (to preserve colormap slots on my 256 color display),
|
|
and tells xv to exit after doing this.
|
|
<P>
|
|
Note that if you run a program like xearth it will continue to run
|
|
after you have started the session and will contiinue to run by default
|
|
until the session is exited. See the 'xdm' man page for more details.
|
|
<P>
|
|
!!!!!!!!!!!!!
|
|
!! WARNING !!
|
|
!!!!!!!!!!!!!
|
|
<P>
|
|
programs run by xdm are usually run as root, and so pose a potential
|
|
security risk if they are not specifically designed for this. You have
|
|
been warned :-)
|
|
<P>
|
|
Andrew M. Dyer
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="two"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Two 2 Cent Tips -- syslog & X Color Depth
|
|
</H3>
|
|
Date: 13 Jan 1997 10:33:29 +0100 <BR>
|
|
From: Marco Melgazzi, <A HREF="mailto:marco@techie.com">marco@techie.com </A>
|
|
<P>
|
|
Dear sirs
|
|
<P>
|
|
Here's two 2c tips for your wonderful Linux Gazette. Note that all
|
|
the lines ending with \ have to be joined on one line.
|
|
<P>
|
|
1. :::: Syslog fun (oh no, not again) :::::
|
|
<P>
|
|
Everybody seem to like to put a line like the following in their
|
|
syslog:
|
|
<PRE>
|
|
*.* /dev/ttyx
|
|
</PRE>
|
|
this way every message is printed on an unused tty and the curious ( or
|
|
worried ) user can switch to it and see what's going on.
|
|
This approach has a big advantage ( it doesn't use any system resource
|
|
) and a couple of disadvantages ( notably you have to switch to text mode
|
|
to read the messages and then you don't have scrollback ).
|
|
So I have this little workaround: in /etc/syslog.conf put something
|
|
like
|
|
<PRE>
|
|
*.* /var/adm/current_session_log
|
|
</PRE>
|
|
In rc.local or whatever file is called before starting syslog
|
|
<PRE>
|
|
/bin/cat /dev/null > /var/adm/current_session_log
|
|
</PRE>
|
|
In fvwm you can add something like this:
|
|
<PRE>
|
|
Style "tail" NoTitle, NoHandles, Sticky, WindowListSkip
|
|
Style "tail" StaysOnTop, CirculateSkip
|
|
|
|
*GoodStuff S-Log telnet-sm.xpm Exec "rxvt" \
|
|
rxvt -geometry 132x45-0+0 -sl 1200 -font fixed \
|
|
-e tail -n 1200 -f /var/adm/current_session_log &
|
|
</PRE>
|
|
So when you press the goodstuff button named 'S-log' you get a big rxvt
|
|
with a nice scrollback buffer that displays exactly what's going on in the
|
|
system. If your linux system stays up for weeks at a time you'll probably
|
|
have to set up a CRON entry that trims this file every once in a while but
|
|
this is left as an exercise for the reader ;-)
|
|
<P>
|
|
To pop down the rxvt a simple Ctrl-C is more than enough. By the way,
|
|
this approach will surely save a lot of stress to the monitor electronics:
|
|
in fact switching from text mode to hires a) takes time b) involves quite a
|
|
lot of non-trivial adjustments in the monitor circuitry so it could likely
|
|
acceelerate its ageing process.
|
|
<P>
|
|
2. ::::: How to use X with more than one color depth ::::::
|
|
<P>
|
|
I normally use X in 8bit ( since my board is not VRAM based 1152x864 at
|
|
70Hz slows down things considerably ) but, since when I hacked my XF86_S3
|
|
to let me use higher clocks in 16bit mode :), occasionally I need to switch
|
|
to the 16bits depth (notably when using the oh-so-amazing 'The Gimp').
|
|
<P>
|
|
Since leaving two servers up and running all the time via xdm seemed a
|
|
waste of memory, by tinkering with manual pages and articles from the net I
|
|
came up with a viable alternative.
|
|
<P>
|
|
Let me first tell you one thing: in this way, when the second server is
|
|
running, you get both :0 (in 8bit) that is managed by xdm and :1 that has
|
|
been started on-demand. Since I don't usually use :1 while I'm online I
|
|
didn't took the time to provide MIT-MAGIC-COOKIE authorization for it: this
|
|
is a thing you -should- do if you plan to use this on the net.
|
|
<P>
|
|
Here there are a couple of my scripts:
|
|
<PRE>
|
|
::: ----------------------------------------------------------------
|
|
:::/usr/local/bin/1open16
|
|
::: ----------------------------------------------------------------
|
|
xinit ~/.x_rc_for_1_16 -- /usr/X11/bin/X16 :1 vt8 &
|
|
|
|
::: ----------------------------------------------------------------
|
|
:::/usr/X11/bin/X16
|
|
::: ----------------------------------------------------------------
|
|
#!/bin/sh
|
|
exec XF86_S3.new -bpp 16 ${@+"$@"}
|
|
|
|
::: ----------------------------------------------------------------
|
|
:::~/.x_rc_for_1_16
|
|
::: ----------------------------------------------------------------
|
|
#!/bin/sh
|
|
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
|
|
|
|
userresources=$HOME/.Xresources_for_1_16
|
|
usermodmap=$HOME/.Xmodmap
|
|
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
|
|
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap
|
|
|
|
export PATH= .... path ....
|
|
|
|
# merge in defaults and keymaps
|
|
|
|
if [ -f $sysresources ]; then
|
|
xrdb -merge -display :1 $sysresources &
|
|
fi
|
|
|
|
if [ -f $sysmodmap ]; then
|
|
xmodmap -display :1 $sysmodmap &
|
|
fi
|
|
|
|
if [ -f $userresources ]; then
|
|
xrdb -merge -display :1 $userresources &
|
|
fi
|
|
|
|
if [ -f $usermodmap ]; then
|
|
xmodmap -display :1 $usermodmap &
|
|
fi
|
|
|
|
....
|
|
misc other variables
|
|
....
|
|
|
|
exec fvwm -f .fvwmrc_for_1_16
|
|
|
|
::: ----------------------------------------------------------------
|
|
::: in ~/.fvwmrc_for_1_16 I have this: I'm not sure this duplication
|
|
::: is necessary but in my configuration it is. YMMV
|
|
::: ----------------------------------------------------------------
|
|
Function "InitFunction"
|
|
Exec "I" xrdb -display :1 -merge ~/.Xresources &
|
|
Exec "I" xmodmap -display :1 ~/.Xmodmap &
|
|
Module "I" GoodStuff
|
|
Exec "I" emacs &
|
|
EndFunction
|
|
</PRE>
|
|
In this way when you execute the 1open16 script you will get a 16bit
|
|
screen on :1 at the default resolution you put in your system XF86Config
|
|
for 16bit depth.
|
|
<P>
|
|
Things get a little more hairy if you want to open the new screen with
|
|
a different set of resolutions: unluckily ( I guess for security reasons )
|
|
XFree lets you use a new XF86Config -only- if you are root. So to play
|
|
Quake on :1 you have to do the following...
|
|
<PRE>
|
|
::: ----------------------------------------------------------------
|
|
::: in ~/.fvwmrc ( this is nice for password requests, I use it all the
|
|
::: time, just put the word 'Password' in the rxvt that you need and use
|
|
::: the supplied style. I use it for going online, to access netscape &
|
|
::: other net stuff ( I'm paranoid so I created a user named -net- that
|
|
::: I use for all internet related stuff, I hate live-data trojans etc.)
|
|
::: you get the point.)
|
|
::: ----------------------------------------------------------------
|
|
Style "*Password" NoTitle, NoHandles, Sticky, WindowListSkip,StaysOnTop
|
|
|
|
::: in a menu entry
|
|
Exec "Quake (normal)" exec rxvt -fn \
|
|
"-b&h-lucidatypewriter-medium-r-*-*-*-180-75-75-*-*-*-*" \
|
|
-geometry 40x1+1-1 -T \"Quake Password" -e \
|
|
su root -c "/home/marco/bin/qk" &
|
|
|
|
::: ----------------------------------------------------------------
|
|
::: /home/marco/bin/qk. The redundant su is needed if you plan to launch
|
|
::: this file from the command line too.
|
|
::: ----------------------------------------------------------------
|
|
cd /home/marco/quake
|
|
su -c "xinit ./xf86quake -- /usr/X11/bin/X -bpp 8 :1 vt8 -xf86config \
|
|
/home/marco/lib/XF86Config.quake"
|
|
</PRE>
|
|
|
|
Of course /home/marco/lib/XF86Config.quake will contain only the
|
|
resolution that I usually play quake at ( that is 400x300 or 512x384 ). In
|
|
this way you can play quake without hassless even if you usually run at
|
|
1000-or-so x 800-or-so at whatever depth. Now if only Linus released the
|
|
updated 1.06 xf86quake ;-) (in 1.01 you can't use a custom heap, you
|
|
have the fixed 8mb one :( ).
|
|
<P>
|
|
Hope you'll like these tips!
|
|
<P>
|
|
Marco Melgazzi
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
</td> </tr> </table>
|
|
<a name="depth"><p></a>
|
|
<table>
|
|
<td><img src="../gx/blank.gif" width=50></td>
|
|
<td>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
X Windows Color Depth
|
|
</H3>
|
|
Date: Fri, 17 Jan 1997 08:38:20 -0500 (EST)<BR>
|
|
From: Aaron B. Dossett, <A HREF="mailto:aarond@ewl.uky.edu">
|
|
aarond@ewl.uky.edu </A>
|
|
<PRE><h5>
|
|
>I have recently been messing with my x-server, and have managed
|
|
>to get a depth of 16, ie 2^16 colors. This works
|
|
>really nice with Netscape, but some programs (doom, abuse, and
|
|
>other games) wont work with this many colors. Do
|
|
>you know of a fix? I have tried to get X to support multiple
|
|
>depths--to no avail. The man-page suggests that some
|
|
>video cards support multiple depths and some don't. How do I know
|
|
>if mine does.
|
|
</h5></PRE>
|
|
Well, if your video card has enough RAM and you've got enough modes defined
|
|
in your XF86Config file then you can specify the bit depth from the command
|
|
line. If you have a link called X to the server then the command
|
|
<PRE>
|
|
X -bpp 8 or X -bpp 16 or X -bpp 24
|
|
</PRE>
|
|
can be used. I like to alias the commands X8, X16, and X24 to the above.
|
|
For this to work best you should have your XF86Config file setup so that
|
|
each mode uses the maximum resolution possible.
|
|
<P>
|
|
Aaron Dossett, aarond@ewl.uky.edu
|
|
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
<A HREF="./index.html"><IMG SRC="../gx/indexnew.gif" ALT="[ TABLE OF
|
|
CONTENTS ]"></A> <A HREF="../index.html"><IMG SRC="../gx/homenew.gif"
|
|
ALT="[ FRONT PAGE ]"></A> <A HREF="lg_mail14.html"><IMG SRC="../gx/back2.gif" ALT=" Back "></A>
|
|
<A HREF="lg_bytes14.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
|
|
|
|
<P> <hr> <P>
|
|
<h5>This page maintained by the Editor of <I>Linux Gazette</I>,
|
|
<A HREF="mailto: gazette@ssc.com">gazette@ssc.com</A><BR>
|
|
Copyright © 1997 Specialized Systems Consultants, Inc. </H5>
|
|
<P>
|
|
</td></tr></table>
|
|
</body>
|
|
</html>
|