ALINK=#FF0000 BACKGROUND="../gx/spirbind.gif">

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


More 2¢ Tips!


Send Linux Tips and Tricks to gazette@linuxgazette.net


Contents:


Another 2cent Script for LG

Date: Wed, 11 Dec 1996 23:34:58 +0100
From: Hans Zoebelein, zocki@goldfish.cube.net

Hello LG people,

here comes a short script which will check from time to time that there is enough free space available on anything which shows up in mount (disks, cdrom, floppy...)

If space runs out, a message is printed every X seconds to the screen and 1 mail message per filled device is fired up.

Enjoy!
Hans

 
#!/bin/sh

# 
# $Id: lg_tips13.html,v 1.2 2002/10/09 22:24:17 lg Exp $
#

#
# Since I got mysterious error messages during compile when
# tmp files filled up my disks, I wrote this to get a warning 
# before disks are full.
#
# If this stuff saved your servers from exploding, 
# send praising email to zocki@goldfish.cube.net.
# If your site burns down because of this, sorry but I 
# warned you: no comps.
# If you really know how to handle sed, please forgive me :)
#

#
# Shoot and forget: Put 'check_hdspace &' in rc.local.
# Checks for free space on devices every $SLEEPTIME sec. 
# You even might check your floppies or tape drives. :)
# If free space is below $MINFREE (kb), it will echo a warning 
# and send one mail for each triggering device to $MAIL_TO_ME.
# If there is more free space than trigger limit again, 
# mail action is also armed again. 
#

# TODO: Different $MINFREE for each device. 
# Free /*tmp dirs securely from old junk stuff if no more free space.


DEVICES='/dev/sda2 /dev/sda8 /dev/sda9'		# device; your put disks here
MINFREE=20480					# kb; below this do warning
SLEEPTIME=10					# sec; sleep between checks
MAIL_TO_ME='root@localhost'			# fool; to whom mail warning


# ------- no changes needed below this line (hopefully :) -------

MINMB=0
ISFREE=0
MAILED=""
let MINMB=$MINFREE/1024 	# yep, we are strict :)

while [ 1 ]; do
	DF="`/bin/df`"
	for DEVICE in $DEVICES ; do
		ISFREE=`echo $DF | sed s#.\*$DEVICE" "\*[0-9]\*" "\*[0-9]\*" "\*## | sed s#" ".\*##`
		
		if [ $ISFREE -le $MINFREE ] ; then
			let ISMB=$ISFREE/1024
			echo  "WARNING: $DEVICE only $ISMB mb free." >&2
			#echo "more stuff here" >&2
			echo -e "\a\a\a\a"
			
			if [ -z  "`echo $MAILED | grep -w $DEVICE`" ] ; then 
				echo "WARNING: $DEVICE only $ISMB mb free.
(Trigger is set to $MINMB mb)" \
				| mail -s "WARNING: $DEVICE only $ISMB mb free!" $MAIL_TO_ME
				MAILEDH="$MAILED $DEVICE"
				MAILED=$MAILEDH
				# put further action here like cleaning 
				# up */tmp dirs...
			fi
		elif [ -n  "`echo $MAILED | grep -w $DEVICE`" ] ; then 
			# Remove mailed marker if enough disk space 
			# again. So we are ready for new mailing action.  
			MAILEDH="`echo $MAILED  | sed s#$DEVICE##`"
			MAILED=$MAILEDH
		fi
	done
	sleep $SLEEPTIME

done


Console Trick Follow-up

Date: Wed, 27 Nov 1996 16:20:06 -0500 (EST)
From: Elliot Lee, sopwith@cuc.edu

Just finished reading issue #12, nice work.

A followup to the "Console Tricks" 2-cent tip:
What I like to do is have a line in /etc/syslog.conf that says:

  
*.*                                                     /dev/tty10
that sends all messages to VC 10, so I can know what's going on whether in X or text mode. Very useful IMHO.

-- Elliot, http://www.redhat.com/


GIF Animations

Date: Thu, 28 Nov 1996 20:41:22 -0600 (CST)
From: Greg Roelofs, newt@pobox.com

I too thought WhirlGIF (Graphics Muse, issue 12) was the greatest thing since sliced bread (well, aside from PNG) when I first discovered it, but for creating animations, it's considerably inferior to Andy Wardley's MultiGIF. The latter can specify tiny sprite images as parts of the animation, not just full images. For my PNG-balls animation (see http://quest.jpl.nasa.gov/PNG/), this resulted in well over a factor-of-two reduction in size (577k to 233k). For another animation with a small, horizontally oscillating (Cylon eyes) sprite, the savings was more than a factor of 20(!).

MultiGIF is available as source code, of course. (And I had nothing to do with it, but I do find it darned handy.)

Regards,
Greg Roelofs, http://pobox.com/~newt/
Newtware, Info-ZIP, PNG Group, U Chicago, Philips Research, ...


Re: How to close and reopen a new /var/adm/messages file

Date: Thu, 05 Dec 1996 01:09:27 -0800
From: CyberTech, CyberTech@ns.cybertech.org

Regarding the posting in issue #12 of your gazette, how to backup the current messages file & recreate, here is an alternative method...

Place the lines at the end of this messages in a shell script (/root/cron/swaplogs in this example). Don't forget to make it +x! Execute it with 'sh scriptname', or by adding the following lines to your (root's) crontab:

 
# Swap logfiles every day at 1 am, local time
0 01 * * *       /root/cron/swaplogs
The advantage to this method over renaming the logfile and creating a new one is that in this method, syslogd is not required to be restarted.
 
#!/bin/sh
cp /var/adm/messages /var/adm/messages.`date +%d-%m-%y_%T`
cat /dev/null >/var/adm/messages

cp /var/adm/syslog /var/adm/syslog.`date +%d-%m-%y_%T`
cat /dev/null >/var/adm/syslog

cp /var/adm/debug /var/adm/debug.`date +%d-%m-%y_%T`
cat /dev/null >/var/adm/debug


How to truncate /var/adm/messages

Date: Mon, 02 Dec 1996 16:47:20 +0100
From: Eje Gustafsson, gne@ffa.se
 
>In answer to the question: 
>
>            What is the proper way to close and reopen a new >/var/adm/messages
>            file from a running system? 
>
>       Step one: rename the file. Syslog will still be writing in it >after renaming so you don't
>       lose messages. Step two: create a new one. After re-initializing >syslogd it will be used.
>just re-initialize. 
>
>          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.
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.

Best of regards,
Eje Gustafsson, System Administrator
THE AERONAUTICAL RESEARCH INSTITUTE OF SWEDEN


Info-ZIP encryption code

Date: Thu, 28 Nov 1996 20:58:39 -0600 (CST)
From: Greg Roelofs, newt@pobox.com

This is a relatively minor point, but Info-ZIP's Zip/UnZip encryption code is *not* DES as reported in Robert Savage's article (LG issue 12). It's actually considerably weaker, so much so that Paul Kocher has pub- lished a known-plaintext attack (the existence of which is undoubtedly the reason PKWARE was granted an export license for the code). While the encryption is good enough to keep your mom and probably your boss from reading your files, those who desire *real* security should look to PGP (which is also based on Info-ZIP code, but only for compression).

And while I'm at it, Linux users will be happy to learn that the upcoming releases of UnZip 5.3 and Zip 2.2 will be noticeably faster than the cur- rent publicly released code. In Zip's case this is due to a work-around for a gcc bug that prevented a key assembler routine from being used--Zip is now 30-40% faster on large files. In UnZip's case the improvement is due to a couple of things, one of which is simply better-optimized CRC code. UnZip 5.3 is about 10-20% faster than 5.2, I believe. The new ver- sions should be released in early January, if all goes well. And then... we start working on multi-part archives. :-)

Greg Roelofs, http://pobox.com/~newt/
Newtware, Info-ZIP, PNG Group, U Chicago, Philips Research, ...


Kernel Compile Woes

Date: Mon, 2 Dec 1996 21:35:29 +0400 (GMT-4)
From: Duncan Hill, dhill@sunbeach.net

Greetings. Having been through hell after a recompile of my kernel, I thought I'd pass this on.

It all started with me compiling a kernel for JAVA binary support..who tell me do that. Somehow I think I got experimental code in..even worse :> Anyway, it resulted in a crash, and I couldn't recompile since then.

Well, after several cries for help, and trying all sorts of stuff, I upgraded binutils to 2.7.0.3, and told the kernel to build elf support and in elf format, and hey presto. I'd been wrestling with the problem for well over a week, and every time, I'd get an error. Unfortunately, I had to take out sound support, so I'm going to see if it'll add back in.

I have to say thank you to the folks on the linux-kernel mailing list at vger.rutgers.edu. I posted there once, and had back at least 5 replies in an hour. (One came back in 10 minutes).

As for the LG, it looks very nice seen thru Lynx 2-6 (no graphics to get messed up :>) I love the Weekend Mechanic, and the 2 cent tips mainly. Perhaps one day I'll contribute something,.

Duncan Hill, Student of the Barbados Community College http://www.sunbeach.net/personal/dhill/dhill.htm http://www.sunbeach.net/personal/dhill/lynx/lynx-main.html


 Letter 1 to the LJ Editor re Titlebar

Date: Sat, 21 Dec 1996 15:18:01 -0600
From: Roger Booth, Roger_Booth@crow.bmc.com
To: linux@ssc.com 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 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 author uses a command-line option to the echo command which is not available on all Unix platforms.

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.

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.

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.

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?

Roger Booth, rbooth@bmc.com


 Letter 2 to the LJ Editor re Titlebar

Date: Fri, 13 Dec 1996 23:03:37 -0700 (MST) From: Gary Masters, gmasters@csn.net

Some further clarification is needed with respect to the X Term Titlebar Function tip in the Linux Gazette Two Cent Tips column of the January 1997 issue. With regard to the -print option to find, Michael Hammel says, "Linux does require this." This is yet another example of "Your mileage may vary." Some versions of Linux do not require the -print option. And, although Solaris may not, SunOS 4.1.3_U1 and 4.1.4 do require the -print option. Also, if running csh or tcsh, remember to escape wildcards in the file specification ( e.g. find ./ -name \*txt\* ) so that the shell doesn't attempt to expand them.

Second, for those tcsh fans out there, here is an xterm title bar function for tcsh.

NOTE: This works on Slackware 3.0 with tcsh version 6.04.00, under the tab, fv, and OpenLook window managers. Your mileage may vary.

if ( $TERM == xterm ) then
  set prompt="%h> "
  alias cwdcmd 'echo -n "^[]2;`whoami` on ${HOST} - $cwd^G^[]1;${HOST}^G"'
  alias vi 'echo -n "^[]2;${HOST} - editing file-> \!*^G" ; vim \!* ;
cwdcmd'
  alias telnet '/bin/telnet \!* ; cwdcmd'
  alias rlogin '/usr/bin/rlogin \!* ; cwdcmd'
  cwdcmd
else
  set prompt="[%m]%~% "
endif
  1. Check to see if tcsh is running in an xterm.
  2. Set the prompt to show the current history event number.
  3. Set the alias cwdcmd to display the user, host, and current path in the xterm title bar, and set the icon name to the host name. cwdcmd is a special tcsh alias, which if set holds a command that will be executed after changing the value of $cwd.
  4. Set a vi alias to display the user, host, and file name under edit in the xterm title bar. And run cwdcmd on exit to restore the xterm title bar and icon name.
  5. Alias telnet and rlogin to restore the xterm title bar and icon name upon exit. NOTE: Paths to telnet and rlogin may vary.
  6. Run the alias cwdcmd to set the initial xterm title bar and icon name.
  7. If this wasn't an xterm, set the prompt to show hostname and path. Gary Masters


PPP redialer script--A Quick Hack

Date: Sun, 08 Dec 1996 13:20:25 +0200
From: Markku J. Salama, msalama@usa.net

This here is the way I do it, but don't use it if your area has some regulations about redialing the same phone numbers over and over:

 
#!/bin/sh

# A quick hack for redialing with ppp by 
# Tries 2 numbers sequentially until connected
# Takes 1 cmdline parm, the interface (ppp0, ppp1...)

# You need 2 copies of the ppp-on script (here called modemon{1,2}) with 
# different telephone numbers for the ISP. These scripts should be
slightly 
# customized so that the passwd is _not_ written in them, but is taken
# separately from the user in the main (a.k.a. this) script. 

# Here's how (from the customized ppp-on a.k.a. modemon1):
# ...
# TELEPHONE=your.isp.number1 # Then make a copy of this script ->
modemon2 
			     # and change this to your.isp.number2
# ACCOUNT=your.account  
# PASSWD=$1                  # This gets the passwd from the main
script.
# ...

# /sbin/ifconfig must be user-executable for this hack to work.
 
wd1=1                                                   # counter start
stty -echo                                              # echo off
echo -n "Password: "                                    # for the ISP
account
read wd2
stty echo                                               # back on
echo                                                    
echo "Trying..."                                        
echo 'ATE V1 M0 &K3 &C1 ^M' > /dev/modem                # modem init, 
                                                        # change as
needed
                                                        
/usr/sbin/modemon1 $wd2                                 # first try
flag=1                                                  # locked

while [ 1 ]; do                                         # just keep on
going

       if [ "$flag" = 1 ]; then                         # locked?

              bar=$(ifconfig | grep -c $1)        # check for a link

              if [ "$bar" = 1 ]; then                   # connected?
                     echo "Connected!"                  # if so, then
                     exit 0                             # get outta here
              else
                     foo=$(ps ax)                       # already
running?
                     blaat=$(echo $foo | grep "/usr/sbin/pppd") 

                     if [ "$blaat" = "" ]; then         # if not, then
                            flag=0                      # unset lock
                     fi
              fi

       else                                             # no lock, ready
                                                        # to continue
              wd1=$[wd1+1]                              
              echo "Trying again... $wd1"

              if [ $[wd1%2] = 1 ]; then                 # this modulo
test
                     /usr/sbin/modemon1 $wd2            # does the
switching
              else                                      # between the 2
numbers
                     /usr/sbin/modemon2 $wd2            # we are using
              fi                                        

              flag=1                                    # locked again
                                                        
       fi

done                                                    # All done!
There. Customize as needed & be an excellent person. Ant DON'T break any laws if redialing is illegal in your area!

Mark


TABLE tags in HTML

Date: Fri, 20 Dec 1996 11:51:22 -0500
From: Michael O'Keefe, Michael.OKeefe@LMC.Ericsson.SE
Organization: Ericsson Research Canada

G'day,

Just browsing through the mailbox, and I noticed your reply to a user about HTML standard compliance and long download times. You replied that you use the spiral image (a common thing these days) inside a <TABLE>.

I hope you are aware that a browser cannot display any contents of a <TABLE> until it has received the </TABLE> tag (no matter what version of any browser - it is a limitation of the HTML tag) because the browser cannot run its algorithm until it has received all of the <TR> and <TD> tags, and it can't be sure of that until the </TABLE> tag@lists.linuxgazette.netes through. I have seen many complex sites, using many images (thankfully they at least used the HEIGHT and WIDTH tags on those images to tell the browser how big the image will be so it didn't have to download it to find out) but still, putting it in a table nullifies much of the speediness that users require.

A solution I often offer the HTML designers under me is to use a <DL><DD> combination. Though this doesn't technically fit the HTML DTD (certain elements are not allowed in a <DL>) and I use an editor that will not allow illegal HTML, so I can't do it myself (without going via a backdoor - but that's bad quality in my opionion). The downside of the this is of course that you don't know what sized FONT the user has set on the browser, and the FONT size affects the indetation width of the <DD> element. But if your spiral image is not too wide, then that could be made a NULL factor. The plus to the <DL><DD> is that the page can be displayed instantly as it comes down (again..providing the developer uses the HEIGHT and WIDTH attributes on *ALL* images so that the browser doesn't have to pause it's display to get the image and work out how to lay out around the image)

Michael O'Keefe


Text File undelete

Date: Sat, 7 Dec 1996 15:00:58 +1300 (NZDT)
From: Michael Hamilton, michael@actrix.gen.nz

Here's a trick I've had to use a few times.

Desperate person's text file undelete.

If you accidentally remove a text file, for example, some email, or the results of a late night programming session, all may not be lost. If the file ever made it to disk, ie it was around for more than 30 seconds, its contents may still be in the disk partition.

You can use the grep command to search the raw disk partition for the contents of file.

For example, recently, I accidentally deleted a piece of email. So I immediately ceased any activity that could modify that partition: in this case I just refrained from saving any files or doing any compiles etc. On other occasions, I've actually gone to the trouble of bring the system down to single user mode, and unmounted the filesystem.

I then used the egrep command on the disk partition: in my case the email message was in /usr/local/home/michael/, so from the output from df, I could see this was in /dev/hdb5

 
  sputnik3:~ % df
  Filesystem         1024-blocks  Used Available Capacity Mounted on
  /dev/hda3              18621    9759     7901     55%   /
  /dev/hdb3             308852  258443    34458     88%   /usr
  /dev/hdb5             466896  407062    35720     92%   /usr/local

  sputnik3:~ % su
  Password:
  [michael@sputnik3 michael]# egrep -50 'ftp.+COL' /dev/hdb5 > /tmp/x
Now I'm ultra careful when fooling around with disk partitions, so I paused to make sure I understood the command syntax BEFORE pressing return. In this case the email contained the word 'ftp' followed by some text followed by the word 'COL'. The message was about 20 lines long, so I used -50 to get all the lines around the phrase. In the past I've used -3000 to make sure I got all the lines of some source code. I directed the output from the egrep to a different disk partition - this prevented it from over writing the message I was looking for.

I then used strings to help me inspect the output

 
  strings /tmp/x | less
Sure enough the email was in there.

This method can't be relied on, all, or some, of the disk space may have already been re-used.

This trick is probably only useful on single user systems. On multi-users systems with high disk activity, the space you free'ed up may have already been reused. And most of use can't just rip the box out from under our users when ever we need to recover a file.

On my home system this trick has come in handy on about three occasions in the past few years - usually when I accidentally trash some of the days work. If what I'm working survives to a point where I feel I made significant progress, it get's backed up onto floppy, so I haven't needed this trick very often.

Michael


 Truncating /var/adm/messages

Date: Tue, 31 Dec 1996 15:32:57 GMT+100
From: Michel Vanaken, michel@idtech.be
Organization: IDtech

Hi !

About the topic "How to truncate /var/adm/messages", here's the way to do it with a shell script :

mv /var/adm/messages /var/adm/messages.prev
touch /var/adm/messages
mv /var/adm/syslog /var/adm/syslog.prev
touch /var/adm/syslog
kill -1 `ps x | grep syslog | grep -v grep | awk '{ print $1 }'`
Happy new year !
Michel


2c Host Trick

Date: Tue, 10 Dec 1996 17:27:46 +0300
From: Paul Makeev, mac@rosprint.ru

In order to make DHCPD by ISC/Vixie to run under Linux, you should have route to host 255.255.255.255. Standard "route" from Slackware distribution does not like the string "route add -host 255.255.255.255 dev eth0". But you can add hostname to your /etc/hosts file with address 255.255.255.255, and use "route add hostname dev eth0" instead. It works.

Paul.


Use of TCSH's :e and :r Extensions

Date: Mon, 02 Dec 1996 23:25:23 -0500
From: Bill C. Riemers, bcr@feynman.com

I'd like to congratulate Jesper Pedersen on his article on tcsh tricks. Tcsh has long been my favorite shell. But most of the features Jesper hit upon are also found in bash. Tcsh's most useful and unique features are its variable/history suffixes.

For example, if after applying a patch one wishes to undo things, by moving the *.orig files to there base names, the :r extension which means to strip the extension comes in handy. e.g.

 
 foreach a ( *.orig )
    mv $a $a:r
 end
The same loop for ksh looks like:
 
  for a in *.orig; do=20
    mv $a `echo $a|sed -e 's,\.orig$,,g'`
  done
Even better, one can use the :e extension to extract the file extension. For example, lets say we we want to do the same thing on compressed files:
 
  foreach a ( *.orig.{gz,Z} )
    mv $a $a:r:r.$a:e
  end
The $a:r:r is the filename without .orig.gz and .orig.Z, we tack the .gz or .Z back on with .$a:e.

Bill


Various notes on 2c tips, Gazette 12

Date: Wed, 04 Dec 1996 15:30:21 -0600
From: Justin Dossey, dossey@ou.edu

I noticed a few overly difficult or unnecessary procedures recommended in the 2c tips section of Issue 12. Since there is more than one, I'm sending it to you:

 
#!/bin/sh
         # lowerit
         # convert all file names in the current directory to lower case 
         # only operates on plain files--does not change the name of
directories
         # will ask for verification before overwriting an existing file
         for x in `ls`
           do
           if [ ! -f $x ]; then
             continue
             fi
           lc=`echo $x  | tr '[A-Z]' '[a-z]'`
           if [ $lc != $x ]; then
             mv -i $x $lc
           fi
           done
Wow. That's a long script. I wouldn't write a script to do that; instead, I would use this command:
 
for i in * ; do [ -f $i ] && mv -i $i `echo $i | tr '[A-Z]' '[a-z]'`;
done;
on the command line.

The contributor says he wrote the script how he did for understandability (see below).

On the next tip, this one about adding and removing users, Geoff is doing fine until that last step. Reboot? Boy, I hope he doesn't reboot every time he removes a user. All you have to do is the first two steps. What sort of processes would that user have going, anyway? An irc bot? Killing the processes with a simple

 
kill -9 `ps -aux |grep ^ |tr -s " " |cut -d " " -f2`
Example, username is foo
 
kill -9 `ps -aux |grep ^foo |tr -s " " |cut -d " " -f2`
That taken care of, let us move to the forgotten root password.

The solution given in the Gazette is the most universal one, but not the easiest one. With both LILO and loadlin, one may provide the boot parameter "single" to boot directly into the default shell with no login or password prompt. From there, one may change or remove any passwords before typing ``init 3``to start multiuser mode. Number of reboots: 1 The other way Number of reboots: 2

That's just about it. Thanks for the great magazine and continuing contribution to the Linux community. The Gazette is a needed element for many linux users on the 'net.

Justin Dossey

Date: Wed, 4 Dec 1996 08:46:24 -0800 (PST)
Subject: Re: lowerit shell script in the LG
From: Phil Hughes, phil@ssc.com

The amazing Justin Dossey wrote:

 
> #!/bin/sh
> for i in * ; do [ -f $i ] && mv -i $i `echo $i | tr '[A-Z]' '[a-z]'`;
> done;
> 
> may be more cryptic than 
...
> 
> but it is a lot nicer to the system (speed & memory-wise) too.
Can't argue. If I had written it for what I considered a high usage situation I would have done it more like you suggested. The intent, however, was to make something that could be easily understood.

Phil Hughes


 Viewing HOWTO Documents

Date: Sun, 22 Dec 1996 09:43:40 -0800
From: Didier Juges, dj@destin.nfds.net

>From a newbie to another, here is a short script that eases looking for and viewing howto documents. My howto's are in /usr/doc/faq/howto/ and are gzipped. The file names are XXX-HOWTO.gz, XXX being the subject. I created the following script called "howto" in the /usr/local/sbin directory:

#!/bin/sh
if [ "$1" = "" ]; then
    ls /usr/doc/faq/howto | less
else
    gunzip -c /usr/doc/faq/howto/$1-HOWTO.gz | less
fi
When called without argument, it displays a directory of the available howto's. Then when entered with the first part of the file name (before the hyphen) as an argument, it unzips (keeping the original intact) then displays the document.

For instance, to view the Serial-HOWTO.gz document, enter: $ howto Serial

Keep up the good work.

Didier


 Xaw-XPM .Xresources troubleshooting tip.

Date: Wed, 18 Dec 1996 17:02:07 +0100 (GMT+0100)
From: Robin Smidsroed, dex@sysedata.no

I'm sure a lot of you folks out there have installed the new Xaw-XPM and like it a lot. But I've had some trouble with it. If I don't install the supplied .Xresources-file, xcalc and some other apps (ghostview is one) segfaults whenever you try to use them.

I found out that the entry which causes this, is this:

*setPixmap: /path/to/an/xpm-file
If this entry isn't in your .Xresources, xcalc and ghostview won't work. Hope some of you out there need this.

And while you're at ghostview, remember to upgrade ghostscript to the latest version to get the new and improved fonts, they certainly look better on paper than the old versions.

Ciao!
Robin

PS: Great mag, now I'm just waiting for the arrival of my copy of LJ


 xterm title bar

Date: Wed, 18 Dec 1996 21:21:47 -0800 (PST) From: bradshaw@nlc.com (Lee Bradshaw)

Hi Guys,

I noticed the "alias for cd xterm title bar tip" from Michael Hammel in the Linux Gazette and wanted to offer a possible improvement for your .bashrc file. A similar solution might work for ksh, but you may need to substitute $HOSTNAME for \h, etc:

if [ "x$TERM" = "xxterm" ]; then
   PS1='\h \w-> \[\033]0;\h \w\007\]'
else
   PS1='\h \w-> '
fi
PS1 is an environment variable used in bash and ksh for storing the normal prompt. \h and \w are shorthand for hostname and working directory in bash. The \[ and \] strings enclose non-printing characters from the prompt so that command line editing will work correctly. The \O33]0; and \007 strings enclose a string which xterm will use for the title bar and icon name. Sorry, I don't remember the codes for setting these independently. (ksh users note: \033 is octal for ESC and \007 is octal for CTRL-G.) This example just changes the title bar and icon names to match the prompt before the cursor.

Any program which changes the xterm title will cause inconsistencies if you try an alias for cd instead of PS1. Consider rlogin to another machine which changes the xterm title. When you quit rlogin, there is nothing to force the xterm title back to the correct value when using the cd alias (at least not until the next cd). This is not a problem when using PS1.

You could still alias vi to change the xterm title bar, but it may not always be correct. If you use ":e filename" to edit a new file, vi will not update the xterm title. I would suggest upgrading to vim (VI iMproved). It has many nice new features in addition to displaying the current filename on the xterm title.

Hopefully this tip is a good starting point for some more experimenting. Good luck!

Lee Bradshaw, bradshaw@nlc.com


[ TABLE OF 
CONTENTS ] [ FRONT PAGE ]  Back  Next


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