Articles!

A Member of the Linux Documentation Project

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

Copyright (c) 1996 John M. Fisk fiskjm@ctrvax.vanderbilt.edu
The LINUX GAZETTE is a member of the LINUX DOCUMENTATION PROJECT.

Table of Contents


An Introduction to AWK

by Cheng Hian Goh <chgoh@rombutan.mit.edu>

Enjoyed the LG so much that I decided to contribute my own 2 cents.

I have always been fascinated by what little languages can do. These days, we have perl, python, tck/tk and what nots which are so complex that they can be intimidating some times. One of my favorate was a little language called "awk", invented by Aho, Weinberger, and Kernighan. The gnu implementation is called "gawk" (what else?).

I won't go into the syntax of the language, since it can be easily figured out from the man page (or better still, buy the book "The AWK Programming Language"). I will however share a few scripts which I wrote to help me get more productive (or more unproductive? given that I'm always tweaking them).

One of the problems which I always had is keeping track of small details, e.g., a phone number, a URL, and email address, the number of the combination to the corridor down the hallway. I tried keeping track of things using "tkpostit" (a postit imitation which runs under tcl/tk, which is quite nice actually), but the painful thing is that finding the information I need is not always easy. I keep notes in different files, which means that I constantly need to figure out which file is used to keep what. I had this idea that I could just have pieces of unstructured text written to a file, and retrieve each chunk based on keywords. So, I created a directory ~/logs under $HOME which has a file named ".log". Unstructured text can be entered from stdin, or the file can be edited using any editor. The only requirement is that there needs to be a "distinguished" record seperator (which is *-* in this case). For convenience, I have the simple bash script in my $HOME/bin, named "addlog" which adds a timestamp and a record separator.

   	echo "["`date`"]" >> ./.log
	cat >> ./.log
	echo "*-*" >> ./.log

With this, I could do

   bash> addlog

      this is a piece of unstructured text about awk
      programs and what i can do for me in making more
      productive.

      ^D
   bash> _

I can now do retrieval based on keywords. The actual program is split into two parts. The first is the bash program which pipes the log file to an awk program. The second is the awk program itself.

This is "listlog" which is just a one-liner bash program:

	cat ./.log | awk -v pattern=$1 -f ~/bin/searchlog

"searchlog" is the awk program which does the work:

	BEGIN   { IGNORECASE=1; RS = "*-*"; nf=split(pattern,array) }
	{ 
 	       hit = 1
   	     for (i=1; i<=nf; i++) {
  	              if ($0 ~ array[i]) ; else hit=0
    	    }
  	      if (hit==1) print
	}	

Note that "listlog" and "addlog" needs to be made executable using "chmod +x <filename>". "searchlog" doesn't.

To retrieve the text fragments in the log file, I just need to cd to the appropriate directory and do a

   bash> listlog "awk text"

which will return the text I just entered, and whatever other passages that matches the two keywords. By setting IGNORECASE to a nonzero value in searchlog, the search is case-insensitive. This can be changed by removing the statment "IGNORECASE=1;".

In the above program, I could have put a fixed path for the log path which saves me from having to cd to ~/logs each time. However I wanted to use the same code to add remarks about files I have in different directories. (After a while, I sometimes couldn't figure out what a particular file is about, so it is nice to be able to add a one-liner description to a file). The above code by default maintain a different .log file in each directory. so if I want to know what memo.tex is about, I can describe it by

	bash> addlog

 	memo.tex 

		this is the memo I sent to boss on
		giving me a pay raise.

	^D

I could then do a

	listlog "memo.tex"

to get this description. Alternatively, I could also ask about pay raise without knowing the filename

        listlog "pay raise"

which will return the same entry. By the way, if there is only one keyword, then the quotes are not needed. If no keywords are specified, listlog returns all entries in the logfile.

I had fun with this. Hope this is useful to someone.

-- 
+-----------------------------+---------------------------------------+
|  Cheng Hian Goh             | email: chgoh@mit.edu                  | 
|  MIT Sloan School of Mgt    | https://rombutan.mit.edu/chgoh.html    |
|  50 Memorial Drive E53-320  | Phone: (617)253-2954                  | 
|  Cambridge MA 02139 USA     | Fax:   (617)258-7579                  |
+-----------------------------+---------------------------------------+


Cheap ANSI Color!

by Jim Valentine (simon@tir.com)

Greetings, I'm just another user/self-admin of Linux and I would have to say that it beats the crap outta anything else I've played with for OS's. Well, this posting is about creating Cheap Ansi color sequences using a Very cool text editor called Joe. I came up with this trick out of pure luck and by rtfm. Well on with the show:

Joe is a pretty nice text editor that should come with all or most distributions of Linux. It's easy like pico and powerful like vi, though I'm sure emacs would blow it away but I've never used emacs (yet). So, to use this trick you need to use joe.

Once you start joe it's just a matter of hitting a couple of command keys. However, you need to know the actual ansi color escape sequences to do this. The command key is the " ` " key, (reversed apostrophy), once you do this, joe will ask at the bottom of the screen what kind of special code you wish to use. Use the left bracet "[". It will make a bold text left bracet.

So by typing: `[[0;31mThis is Red text!`[[1;0m will create red text on the default background, then return the next instance of text back to normal.

I've included some of the color sequence codes here for you to use.

Code            Color
-----------------------------
[0;30m       |	black text
[0;31m	     |	red
[0;32m       |	green
[0;33m       |	blue
[0;34m       |	purple
[0;35m       |  cyan
[0;36m       |  silver
[0;40m       |  red back.
[0;41m       |  green back.
[0;42m       |	brown back.
[0;43m       |	blue back.
[0;44m       |	purple back.
[0;45m       |	cyan back.
[0;46m       |	silver back.

Ok, now that that is done, here is some explaination of additional codes you can use to make the colors either bold or blinking.

0 is for default color.
1 is for bold (ie. blue becomes light blue)
5 is for blinking.
2J will clear the screen.

Don't forget to put the small cast 'm' at the end of each code. Also, once the color has been started, it will stay that way until another code has been issued. That's why I use the sequence [1;0m to return it back to the default text color.

I use color quite often, just to make the system a little more lively. It can be used in the motd file, or any other file that will be cat'd. If your terminal doesn't support color then your out of luck.

Have fun and enjoy.

Jim Valentine (simon@tir.com)


DIRED
DISTANT RELATIVE of GNU 'LS'

by Grant B. Gustafson, Univ of Utah
gustafson@math.utah.edu

WHAT IS DIRED?

Suppose you already know color LS. A way to describe DIRED is it is a cousin of LS with superficial resemblances apparent. DIRED and LS share listing abilities and colorization. DIRED can take action on the file names, whereas LS provides information only.

MIDNIGHT COMMANDER and NORTON COMMANDER. No, DIRED is not one of these. Not many system administrators use 'commanders', but they would use LS and DIRED to carry out daily work.

PHILOSOPHY

The DIRED philosophy assumes the person at the keyboard already knows enough unix commands and has no need to learn more. The service of DIRED is to make it easy to insert file names into unix commands. DIRED could have been written as a shell script or Perl script, much in the spirit of the SlackWare programs SETUP and PKGTOOL, but for historic reasons it's in language C. The design is one big switch statement, each level of which calls basic functions, similar to the design of Stallman's emacs. Due to standard design ideas, system programmers immediately understand DIRED as something they could have written with little effort (and B E T T E R).

DIRED ILLUSTRATED BY EXAMPLE

SOUND EXAMPLE: Find sound files in the /usr tree and listen to the interesting ones.

DIRED is invoked as 'dired /usr'. We know that PLAY is a unix command that can play most sound files. When a file is found that looks like a sound file, then invoke the command PLAY on that file. DIRED allows repeating the last command by pressing PERIOD, so typing is minimal. The time is spent searching for something interesting and then listening to the sound.

MCOPY EXAMPLE: Find some ZIP archives in the /DOS tree and copy them to a floppy disk.

DIRED is invoked as 'dired /DOS'. When a ZIP file is located, then press 'm' to invoke the pager LESS, which shows the ZIP file contents. Those files which are destined for the floppy are tagged (TAB key) and when enough are found, the whole group is copied to floppy with the MCOPY command from MTOOLS.

FREEUP DISK SPACE EXAMPLE: Find files to delete in /tmp, but archive them first to a ZIP archive, then delete.

DIRED is invoked as 'dired /tmp'. Tag the files (TAB key) to be archived, then run the unix command ZIP on each file to copy them all into a ZIP archive. Finally, change all the tags to 'D' and exit DIRED, whereupon the physical delete occurs.

THREE NORMAL DIRED FUNCTIONS

PRUNING. Files and directories can be tagged 'D' for deletion, the physical remove taking place all at once, on demand or on exit.

NAVIGATION. Follow directory trees up and down to see what's there, using cursor keys and the 'e' or 'E' commands ('e' for EDIT). During navigation, links and directories are identified. There's a regular expression search and sorting to make it comfortable. And on-the-fly screen configuration.

BROWSE. Looking inside files is passed to the programs LESS and LESSPIPE.SH, which intelligently view regular files, man pages, rpm source archives, cpio, tar, zip, tar.z, tar.Z, gzip and compress archives. There is an internal CAT program for fast viewing of text and binary files. To fix a file, the system EDITOR is invoked.

HOW TO GET DIRED

Get https://sunsite.unc.edu/pub/Linux/utils/file/managers/dired301.tgz and use the command "cd /; tar -xzf dired301.tgz" to put the executable and manual page where they belong. A side effect is the deposit of the sources in /usr/src/dired301 (they can be deleted).

The currently available version of DIRED is 3.01, June 1996. The sources are subject to the GNU Public License Agreement (GPL), which means the whole package is transferred, with source. To compile the package requires the GNU C compiler and MAKE; there are two source files, dired.c and regexp.c.

LIMITATIONS

Yes, it is limited in scope and features. Any programmer is going to find something missing. If enough programmers contribute to it, then either it will grow into a monster or else shrink to the essential minimum, a migration into maturity that LS enjoys. Since DIRED has been around since 1980, one would think the maturity is a given. Not so! Every year someone thinks of a new feature or discovers a new bug.

*-----------------------------------------------------------------*
| Grant B. Gustafson             | (801) 581-6879    FAX 581-4148 |
| 113 JWB, Dept Math, U. of Utah | email: gustafso@math.utah.edu  |
| Salt Lake City, UT 84112       | URL: https://www.math.utah.edu/ |
*-----------------------------------------------------------------*


Securing your RM!

Christophe Blaess <ccb@club-internet.fr>

This is a shell script for Bash, called 'rm_secure'. I use it as frontal for the rm command. It stores the deleted files in an archive in the user's directory. A command-line option allows the user to view the content of this archive, and another option permits the restoration of the deleted files.

For example :

$ ls -l
$ ls -l
$ rm --viewtrash
-rw-r--r--  1 ccb   users    22 May 26 10:35 1996 important_file
-rw-r--r--  1 ccb   users    23 May 26 10:35 1996 not_important
$ rm --restore important_file
$ ls -l
-rw-r--r--  1 ccb   users    22 May 26 10:35 important_file
$ rm --viewtrash
-rw-r--r--  1 ccb   users    23 May 26 10:35 1996 not_important
$ rm --emptytrash
$ rm --viewtrash

Okay, it slows down a few the rm command. But it may also save hours of work lost due to a keystroke error...

There is the script 'rm_secure' :

#!/bin/bash

# Configuration

# the real 'rm' command
bin_rm=/bin/rm  

# where archiving the files
Archive=~/.rm_saved.tar
# you may prefer something like :
# Archive=/var/trash/$USER/saved_file.tar
# (with write access permission on the directory)

# global variables for the options
Opt_recursive=0
Opt_no_secure=0
Opt_restore=0
Opt_rm=""

# function for archiving a file or a directory
save_file() {
  if [ $Opt_no_secure -ne 1 ] ; then
    # set date/time of deletion
    touch "$1" > /dev/null 2>&1 
    if [ -f $Archive ] ; then
      tar --delete -f "$Archive" "$1" > /dev/null 2>&1
      tar -rf "$Archive" "$1" > /dev/null 2>&1
    else
      tar -cf "$Archive" "$1" > /dev/null 2>&1
      # r/w access only for the user
      chmod 600 "$Archive"
    fi
  fi
}

# function for restoring file or directory
restore_file () {
  if [ -f $Archive ] ; then
    tar -xf "$Archive" "$1" > /dev/null 2>&1
    tar --delete -f "$Archive" "$1" > /dev/null 2>&1
  fi  
}


# reading the command-line args
while getopts "dfirRvns-:" opt ; do
  case $opt in 
    d )  Opt_rm="$Opt_rm -d" ;;
    f )  Opt_rm="$Opt_rm -f" ;;
    i )  Opt_rm="$Opt_rm -i" ;;
    r | R )  Opt_recursive=1
             Opt_rm="$Opt_rm -r" ;;
    v )  Opt_rm="$Opt_rm -v" ;;
    n )  Opt_no_secure=1 ;;
    s )  Option_restore=1 ;;
    - )  case $OPTARG in
           directory )   Opt_rm="$Opt_rm -d" ;;
           force )       Opt_rm="$Opt_rm -f" ;;
           interactive ) Opt_rm="$Opt_rm -i" ;;
           recursive )   Opt_recursive=1 
                         Opt_rm="$Opt_rm -r" ;;
           help )        $bin_rm --help
             echo "(rm_secure)"
             echo "  -n, --nosecure        delete without backup"
             echo "      --viewtrash       list the saved files"
             echo "      --emptytrash      erase the saved files"
             echo "  -s, --restore         restore the specified files"
                         exit 0 ;;
           version )     $bin_rm --version
                         echo "(rm_secure 1.0)"
                         exit 0 ;;
           verbose )     Opt_rm="$Opt_rm -v" ;;
           viewtrash )   if [ -f $Archive.gz ] ; then
                           tar -tvzf $Archive.gz
                         fi
                         exit 0 ;;
           nosecure )    Opt_no_secure=1 ;;
           emptytrash )  if [ -f $Archive.gz ] ; then
                           $bin_rm $Archive.gz
                         fi
                         exit 0 ;;
           restore )     Opt_restore=1 ;;
           * )           ;;
         esac ;;
    ? )  ;;
  esac
done

shift $(($OPTIND - 1))

gunzip $Archive.gz > /dev/null 2>&1

# restoration ?
if [ $Opt_restore -ne 0 ] ; then
  while [ -n "$1" ] ; do
    restore_file "$1"
    shift
  done
  exit 0
else
  while [ -n "$1" ] ; do
    if [ -d "$1" ] ; then
      # the directories are archived only with
      # the -r option
      if [ $Opt_recursive -ne 0 ] ; then
        save_file "$1"
      fi
      $bin_rm $Opt_rm $1    
    elif [ -e "$1" ] ; then
      # existing file
      save_file "$1"
      $bin_rm $Opt_rm $1
    else
      # let 'rm' give his error message
      $bin_rm $1
    fi
    shift
  done
fi

nice gzip $Archive > /dev/null 2>&1 &

# -- end of script --

Place it in /usr/bin or /usr/local/bin then insert a line:

  alias rm='/usr/local/bin/rm_secure'

in /etc/profile, so this script will be called by Bash in the place of the true rm command.

You can use the '--nosecure' or '-n' option to delete a file without archiving it. This is useful when you decide to erase huge amount of files in recursive directories (for example a package you have tested but find uninteresting).

I use a cron job to deleted the archived files every day (running as root job).

#crontab -l
 [ ...]
00 04 * * *    /usr/local/bin/empty_trash
#

Here is the 'empty_trash' script :

#! /bin/bash
for user in /home/* ; do
  /bin/rm $user/.rm_saved.tar.gz
done
/bin/rm /root/.rm_saved.tar.gz
# -- end of script --

Maybe you can prefer something like :

  trap '/bin/rm ~/.rm_saved.tar.gz EXIT

in /etc/profile, which erase the archive each time the user exits the shell. (I've not fully tested this)

Obviously this tips doesn't secure the deletion of files or directories by a file-manager, but I find it quite usefull, especially when doing administrative jobs as root ('rm tmp/ *' in place of 'rm tmp/*' ...)

                          ____
                         /    /
 Christophe BLAESS      / Cabinet
                       / Conseil
ccb@club-internet.fr  / Blaess
                     /____/_____


TAR'ing Over the Net!

by Mark A. Bentley <bentlema@cs.umn.edu>

Okay, this is useful if it is a pain to mount a remote filesystem via NFS. I.e. if you don't have root on the machine with the tape drive, but you do have access to write to the tape device.

First make sure you can rsh to the machine with the tape drive. You can test this from the remote machine by executing a simple command like ls. For example, if your on thufir.cs and you want to see if you have rsh permissions on caesar, do this at the shell prompt:

thufir% rsh caesar.cs ls

You should get a directory listing back. If you get "Permission denied" you have to add the hostname of the remote machine to the .rhosts file in your home directory on the remote machine. The full hostname is required, and be careful if your remote machine has multiple interfaces (i.e. ATM and 10BASE-2). You have to use the hostname that corisponds the the interface you will be using.

Anyway, once this is setup, you can use tar, rsh, and dd to dump your data across the net to a tape device. For example:

thufir%  tar cBf - /local-directory | rsh caesar.cs dd of=/dev/tape

Note: dd will automatically take it's input from stdin if not spcified. Also, you have to find out the name of the tape device on the remote machine. For example, on a Solaris machine, it might be /dev/nrst37.

Also, you can dump any type of data across the net this way. There's nothing special about tar...

Have fun...

--
Mark Bentley
Computer Science Systems Staff
University of Minnesota, Twin Cities Campus


Taking full advantage of Tcsh - precmd

by Ryan <rmrichar@crimson.student.syr.edu>

As an aspiring C programmer, I was strongly attracted to csh when I was first introduced to UNIX a few short years ago. Since then, I have found comfort in the tcsh shell, with its superior command-line editing and history processing. One thing that bothered me about tcsh was the fact that it doesn't notify you when you have new mail. Bash offers the MAIL and MAILCHECK enviornment variables (see manual page for bash) to provide such a system. Here's very simple idea for us tcsh users to try out.

Tcsh offers a severly under-rated facility called 'precmd.' This is actually just a reserved word in the alias facility. By setting an alias with this name, tcsh will execute the alias before printing each prompt. Here's an example of this:

	crimson:~> alias precmd date
	Sat Mar 30 00:46:19 EST 1996
	crimson:~> uname -a
	Linux crimson 1.2.13 #1 Fri Dec 15 17:55:58 EST 1995 i486
	Sat Mar 30 00:46:40 EST 1996
	crimson:~> 

This is kind of neat, but what does it have to do with mail? Well, if we can write a shell script to check for new mail for us, then we can run it before every prompt is printed. The precmd alias can run anything. If we wanted to, we could alias precmd to 'netscape &' and start a copy of that browser everytime a new prompt should be printed. This would be pointless, and no system in the world has enough memory to run that many copies of Netscape anyway. :) An obviously silly example, but it does make a point. Whatever is set up as a precmd should be as small and sleek as possible.

So what we need is a sleek shell program to check for new mail and notify us if we have mail in our queue. By defining the problem, we have practically already found our solution. Try this on for size:

	if ( -e /var/spool/mail/rmrichar ) 
	  if ( ! ( -z /var/spool/mail/rmrichar ) ) 
	    echo You have mail.

What is this? Well, you could read this as "if my mail spool exists, and if it is also not empty, then echo a message to my screen." (Refer to the tcsh man page for more information here.) All we need to do now is alias this so it runs before each prompt is printed. This can be achieved in the same way that you alias anything, with one little exception. If you type this in as is, your system will complain about 'Badly placed (.' All you need to do to overcome this is wrap our little script in double quotes when you alias it.

The last step in the process is to generalize our work so we can put it in our /etc/csh.login file. Remember that this is the file that runs for all C-shell users on your system as they login. This last step is also very simple. All we need to do is alter the script and add this a single line to our csh.login:

alias precmd "if ( -e $MAIL ) if ( ! ( -z $MAIL ) ) echo You have mail."

Ta-Dah! We have now seen how to make perfect use of tcsh's precmd alias. Similar special aliases with all sorts of great uses can be found on the tcsh man page. Straight from the man page:

       cwdcmd    the command is run after every change of working
                 directory.
       periodic  the command to be run every tperiod minutes.
       beepcmd   the  command  to be run every time tcsh wants to
                 echo the terminal bell.

Beepcmd is great for Mac and MS-Windows users. By writing an equally simple bit of shell code, you can play all of your favorite error bells and whistles as your shell's "system beep". (See the Gazette's "Changing that xterm titlebar interactively" for a great use of cwdcmd. Also see the Gazette's "FVWM and Audio by Nic Tjirkalli" for more about nifty system sounds.)

Tcsh has a multitude of useful mechanisms like these. Read the man page to find out all about completion, prompt formats, history, and even monitoring logins. Tcsh is a great shell, so have some fun with it!


Customizing Logins with XDM

by Yann Le Fablec <lefablec@eis.enac.dgac.fr>

Part 1 : What's xdm and how to install it

Xdm stands for X Display Manager, it provides a graphical login instead of the usual text one. To install it, first get it (disk x6/x312cfg.tgz and x7/x312bin.tgz from the Slackware Release 3.0 or in any sunsite mirrors in the directory X11/xutils/xdm.tar.gz) then compile it if needed or just follow installation steps. After that, you have to make it active from the boot sequence :

When booting is finished, you get a graphical login asking your login and password. If you log in, it's probable that you'll see that your environment has disappeared : none of your preferences are active as they used to. Don't worry, we're gonna solve this problem. will setup what you want.

Part 2 : Configuring your login session

There are two ways to do : either you create a .xsession file which will only be a copy of the '.xinitrc' file, either you change you '.xinitrc' rights to make it executable. The second method if obviously the fastest but if you choose the first one, what's important once you've made the copy is to set it's rights so that it can be executed : type 'chmod o+x .xsession' to have it done. (You have to set these rights because the '.xinitrc' isn't executable as a default). Your .xsession should look like this :

-------------------------------------------------------------------------
#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# Here starts my environment configuration
# Set the background with the picture sgwbm.jpg
xv -root -rmode 5 -quit /users/yann/Pictures/sgwbm.jpg
# Start a clock in the uppper left corner
/usr/local/bin/emiclock -geometry +0+0&
# Start bowman as my Window Manager
# (could be another one such as fvwm or mwm)
/usr/X11R6/bin/bowman > /users/yann/log
-------------------------------------------------------------------------

Try it : logout and login again.

Now you may have noticed that you have a console window on you desktop. You can get rid of it if you don't like it. In fact it's already present when the graphical login starts so you can guess that it is started in one of xdm configuration files. Theses files are located in /usr/X11R6/lib/X11/xdm/ so cd to that directory.

Note that in order to modify any file in this directory you need to be root.

You can launch new programs in the 'Xsetup_0' file so make a copy before modifying it. Edit it, it looks like this :

#!/bin/sh
# $XConsortium: Xsetup_0,v 1.3 93/09/28 14:30:31 gildea Exp $
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnFail

You can see that the console window is started here so comment it (with a #) to get rid of it. What you can do now is add some new lines to change the background or start a clock for example. My 'Xsetup_0' is :

#!/bin/sh
# $XConsortium: Xsetup_0,v 1.3 93/09/28 14:30:31 gildea Exp $
#xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnFail
# Change background to display a picture
xv -root -rmode 5 -quit /users/yann/Pictures/somtrace.gif
# Start a clock above the login window
xclock -digital -update 1 -geometry +530+100 &
# Start the xsnow program (why not ?)
xsnow > /dev/null &

If you try it, you'll discover that once you're logged in, the xclock and xsnow programs are still running so you may want to stop them before in order not to have to kill them by hand each time you log in. You can do that by modifying the GiveConsole script because it's executed after you typed your password and before your environment comes up. By default it contains :

#!/bin/sh
# Assign ownership of the console to the invoking user
# $XConsortium: GiveConsole,v 1.2 93/09/28 14:29:20 gildea Exp $
#
# By convention, both xconsole and xterm -C check that the
# console is owned by the invoking user and is readable before attaching
# the console output.  This way a random user can invoke xterm -C without
# causing serious grief.
#
chown $USER /dev/console

In our case, we want to kill the xclock and xsnow processes, so we should modify it like this :
#!/bin/sh
# Assign ownership of the console to the invoking user
# $XConsortium: GiveConsole,v 1.2 93/09/28 14:29:20 gildea Exp $
#
# By convention, both xconsole and xterm -C check that the
# console is owned by the invoking user and is readable before attaching
# the console output.  This way a random user can invoke xterm -C without
# causing serious grief.
#
chown $USER /dev/console
# Get list of processes related to xclock (xclock itself and the grep command)
processes=`ps -x | grep "xclock" | awk '{print $1}'`
# Get first id in this list : it corresponds to xclock
id=`echo $processes | awk '{print $1}'
# Kill the process
kill -9 $id > /dev/null
# Do the same thing for xsnow
processes=`ps -x | grep "xsnow" | awk '{print $1}'`
id=`echo $processes | awk '{print $1}'`
kill -9 $id > /dev/null

I know it's a bit brutal to do it that way so if you have better ideas let me know.

Ok, now you've configured your graphical login sequence so enjoy !

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

     Yann Le Fablec
     Ecole Nationale de l'Aviation Civile

     Tel : 62.17.41.59
     E-mail : lefablec@eis.enac.dgac.fr
     http   : https://www.eis.enac.dgac.fr:8001/~lefablec/Welcome.html

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


Announcing ZLISTER

by Joe Wulf <swulf@infi.net>

(Joe and I have been exchanging email for a bit now and he asked if I'd be willing to include this LSM description of his zlister program -- something that I was quite happy to do. In addition, he's made a copy of this program available so that you can pick up a copy of it using the link at the end of the LSM form. Have fun with this and let me know what you think! -- John)

Begin3
Title:          zlister
Version:        1.4
Entered-date:	18MAY96 @ 17:50 EDT
Description:	Combination of csh and awk scripts designed to manage the
                collection, compression, differentiation and storage of
                complete filesystem listings.  It is an administrative support
                tool that will identify changes to any file in the filesystem.
                When executed on a frequent basis (i.e. daily), the resulting
                .diff output can provide invaluable clues to system/security
                administrative personnel as to EVERY file which changes on the
                system listed.  In conjunction with frequent (daily) system
                backups, the potential for any form of data loss can be
                significantly reduced.  Of course, the benefits will be
                maximized with appropriate attention to the output.  This is
                an ideal product to execute on newly built and/or rebuilt
                production servers to get/establish/document the baseline of
                the complete filesystem.  Subsequent runs will highlight
                differences.  Especially benificial to be ran after a
                filesystem check (fsck) has been run and significant errors
                were reported/corrected.  Copious documentation and
                installation instructions are provided in the primary
                'zlister' script.  These scripts were designed to execute,
                without modification, on Solaris (V: 2.3, 2.4 and 2.5), HP-UX
                (V: 9.0.01 - 10.0) and under all versions of Linux
                (V: 1.1.59+).
                I'm very interested in feedback from implementator(s) on
                other *NIX platforms.  Unfortunately, my internet email
                address will cease to exist after 96 Jun 30.  At that time I
                will only have snail mail available to me :( at:
                     DP1 Joe Wulf
                     USNS Spica (T-AFS 9)
                     FPO AP 96678-4066
                I'm looking for people willing to help me manage this project
                and edit the scripts to get them to work on their platform.
                If you are interested in doing this, please write me and let
                me know what plaform (and version of unix).
Keywords:	filesystem ls ls-laR admin tool csh awk scripts
Author: 	swulf@infi.net (Joe Wulf)    # Only until 960730
                huntj@wangfed.com (Jim Hunt) # Alternate Point of Contact.
Primary-site:	sunsite.unc.edu:/pub/Linux/system/admin
                66K zlister.taz
                 3K zlister.lsm
Alternate-site: 
Original-site:	
Platforms:	Currently functions with out modification on Solaris, HP
                and Linux boxes; will funtion on other *NIX's with only
                minor modifications (fully explained in the scripts).
Copying-policy:	GPL

Get a copy of zlister


Well, thanks SO very much again to everyone that wrote and submitted articles. There is just NO way that the 'ol LG could continue without all of the ongoing encouragement, support, and hard work by so many folks.

Hope you Enjoyed!

John

Back to Linux Gazette #8