From: afx@muc.ibm.de (Andreas Siegert)
Newsgroups: comp.unix.aix,bit.listserv.aix-l
Subject: AIXTIPS NEWS 92221
Date: 29 Jul 92 11:50:25 GMT
Reply-To: aixtips@ibm.de
Followup-To: comp.unix.aix
Organization: IBM AIX Field Support Center, Munich

Sorry for the late delivery but I was far away from my Internet connection
for a while.

This is AIXTIPS NEWS for customers released at Fri the 03. Jul 1992.

Table of contents:
92221. How do you find out if you run on a diskless machine?
92224. Using HP DeskJet 500C with RISC/6000
92226. What caused the system to 888/crash?   Use:  ERRDEAD
92227. Using Xterm on AIX 3.2 without clobbering /etc/utmp
92228. Automounter fixes for 3.2.1
92231. To which lpp belongs this file? (AIX 3.2 version)
92232. How-To read/decode ARP output
92233. Useful info on re-sizing primary paging space
92236. A more colorfoul directory listing
92239. HOTW: Is the 'pg' (page) command too plain?
======================================================================
 
Note:
The information in this document has not been submitted to any formal IBM test
or review and is distributed on an "as is" basis without any warranty either
expressed or implied. The use of this information is a customer responsibility
and customers attempting to adapt these techniques to their own environment
do so at their own risk.

Some of the tips might reference internal TOOLS disks for more information.
Please contact your IBM representative if you need those documents.

Your AIXTIPS Team 		              Internet: aixtips@ibm.de
======================================================================
>92221. How do you find out if you run on a diskless machine?

I think the best way to determine if you're a diskless machine or not is to
execute the "bootinfo" command.  "bootinfo" will look in the ipl control block
and echo to stdout a number which corresponds to the type of device which was
used to obtain the boot image from (ie., which device was booted off of).  In
order to get this information from "bootinfo", use the "-t" flag :

        bootinfo -t

I don't know if there is a .h file which relates what is returned from
bootinfo with a type of device, but here are what the returned numbers mean :

        1 = disk boot
        2 = diskette boot
        3 = cdrom boot
        4 = tape boot
        5 = network boot

In order to execute bootinfo, however, you must have root authority.
--
Donald Long
======================================================================
>92224. Using HP DeskJet 500C with RISC/6000

Turning your HP 500C into a Color PostScript printer.

Here are the steps to be able to use the HP500C for color PostScript
on a RS6K.

1) Connect your HP500C to the parallel printer port.

2) Configure your printer as a HP LaserJet II using SMIT.

3) Get the GhostScript (GS) 2.4.1 package from your favorite Free Software
   Foundation (FSF) source.

4) Compile GS with the RS6K options specified in the Makefile.
   Be sure to include the HP500C device support in the options.

5) run GS as shown

      gs -sDEVICE=djet500c -sOUTPUTFILE=outputfilename inputfile.ps

    where "outputfilename" is the file you want for the 500C printer
    commands and inputfile.ps is the color PostScript source.

6) issue the AIX command

       qprt -d p outputfilename

    where "outputfilename" is the 500C printer command file.
    This will send the 500C printer commands to the printer
    that you've specified with your environment variable PRINTENV.
    It also bypasses any default printer driver or translation
    tables used for the default printers.

  Documentation that comes with GS 2.4.1 tells you how to use the "gs"
  command to send your output directly to the printer, go figure.

         John
======================================================================
>92226. What caused the system to 888/crash?   Use:  ERRDEAD

   Ever wonder what caused your system  to  888/crash?  The  ERRDEAD
   command  extracts  error  records that were in memory and had not
   yet been written to the error log when the system dumped.

   Note:  The ERRDEAD command REQUIRES that you have a  dump  device
        enabled.  Typically this is /dev/rhd7.

   Example:

        #errpt -a | pg                #  what do we find in the error log ?

        #/usr/lib/errdead /dev/hd7    #  any error records in the dump ?

        #errpt -a | pg                #  browse the error log - whatznew ?

   For additional information checkout the pub:

        DIAGNOSTIC PROGRAMS:  SERVICE GUIDE;

             Chapter 2, "Reading Flashing 888 Numbers" ...... 2-2


 inspired by:  jk
======================================================================
>92227. Using Xterm on AIX 3.2 without clobbering /etc/utmp

Xterm has a severe bug which will clobber /etc/utmp.
I have added the following lines of code to main.c:

1. include near the top of the file:

#ifdef AIXV3
#define HAS_UTMP_UT_HOST
#define HAS_BSD_GROUPS
#endif /* AIXV3 */

2. now search for CLOCAL, there is only one occurrence and add the lines
I have marked with a >>: (and keep in mind, the | should be a pipe-sign)

        /* set some flags that should be on */
        terminal_modes.c_oflag |= OPOST;
        /* set some flags that should be on */

>>      /* set some flags that should be on */
>>      terminal_modes.c_lflag |= ECHO;
>>      /* set some flags that should be on */

        /* set some flags that should be off */
        terminal_modes.c_cflag &= ~( CLOCAL ); <<< and this ~ remains a tilde
        /* set some flags that should be off */

3. now recompile and xterm nomore clobbers utmp and allows input even if
started in the background :-).
It works for me; enjoy.
regards,
uwe untermarzoner
======================================================================
>92228. Automounter fixes for 3.2.1

Get this ptf for the latest sun 4.1.1 automounter
U404456 nfs320  IX26018 51189   9222    bosnet

======================================================================
>92231. To which lpp belongs this file? (AIX 3.2 version)

#!/bin/ksh
#
# shell script to tell you which "lpp" contains a particular file or directory
# syntax:  whichlpp [path1] [path2] [path3] ... [pathN]
#
# All the spaces below are VERY important....
#
# Parentheses       - ()
# Square brackets   - []
# Curly  brackets   - {}
# Double quote      - "
# Single quote      - '
# Back single quote - `
# Forward slash     - /  
# Back slash        - \  
#
# For more information, see InfoExplorer and odmget, inventory, and lpp.
#         -Mickey Coggins,
#              with TONS of help from the *amazing* Stephan Langenfeld

ODMDIR=/usr/lib/objrepos
for FILENAME ; do
	if [[ `basename $FILENAME` != $FILENAME ]] ; then
		stanza=`odmget -q"loc0 = $FILENAME" inventory`
            if [[ -z "$stanza" ]] ; then                               
               echo "Couldn't find "$FILENAME" with an exact search."  
               echo "Try entering simply "\"`basename $FILENAME`\"     
            fi
	else
		stanza=`odmget -q"loc0 like */$FILENAME" inventory`
	fi
	stanza=`echo $stanza` # converts all newlines to spaces
	# do it while some chars to process
	while (( ${#stanza} > 1 )) ; do

		# get right part of string,
		# which is the last stanza in the list
		tmpstanza=${stanza##*inventory:}

		lpp_ids=${tmpstanza#*lpp_id = }
		lpp_ids=${lpp_ids%% *}
		names0=${tmpstanza#*loc0 = \"}
		names0=${names0%%\"*}
		names1=${tmpstanza#*loc1 = \"}
		names1=${names1%%\"*}
		names2=${tmpstanza#*loc2 = \"}
		names2=${names2%%\"*}

		for id in $lpp_ids ; do
			name=`odmget -q"lpp_id = $id" lpp | grep name`
			name=${name#*name = \"}
			name=${name%%\"*}
			echo lppname: $name
			echo -n "location: $names0"
			if [[ x$names1 != x ]] ; then
				echo -n "  hard links: $names1"
			fi
			if [[ x$names2 != x ]] ; then
				echo -n "  soft links: $names2"
			fi
			echo
		done

		# chop off the last entry in the list
		stanza=${stanza%inventory:*}
	done
done
                    
======================================================================
>92232. How-To read/decode ARP output

 Need the IP ADDRESS of a remote host?  Use ARP.
 Curious if another system is on the local segment or remote?  Use ARP.

 ARP (address resolution protocol) is one of the lesser known
 protocols that makes up the TCP/IP protocol stack.

 Example:

         $arp pippi
         pippi (19.21.4.YYY) at 50:00:xx:xx:xx:xx [token ring] rt=6b0:321:40

         $arp syclone
         syclone (19.21.4.ZZZ) at 50:00:xx:xx:xx:xx [token ring] rt=630:321:40

 Explanation:

         The RT field is the route (i.e. rings/bridges).  The first byte is
         the routing control field.  The rest is the rings and bridges used.

         Routing Control = BBBLLLLL DFFFrrrr

                       B = Broadcast indicators
                       L = Length bits
                       D = Direction bits (0=left to right; 1=right to left)
                       F = Larges Frame bits
                       r = reserved bits

              06B0 decodes:

                   Non-Broadcast
                   6 bytes of routing info
                   route is from right to left
                   largest frame = 4472

              321:40 decodes:

                   From ring 032, bridge 1 to ring 040

 Thanx to ST.
======================================================================
>92233. Useful info on re-sizing primary paging space

 ENTER AT YOUR OWN RISC!

 Scenario: You have an RS/6000 on which you want to install a large
           application or the Munich TMSC demos.

           The primary paging space (hd6) is 80Mb. The secondary paging
           space (hd61) is 32Mb. The machine has 32Mb of system memory.

           The available free disk space is 20Mb less than you need.

 Every been in this situation (Mike Hall - raise your hand).

 The following info will let you re-define the primary paging space to the
 correct size and regain all that valuable disk space.

 This is only applicable on 3.2 systems.

 Follow these instructions carefully - especially the rebuilding of the
 boot logical volume image and make sure that this command completes
 before re-booting or it's re-install time!

 o Comment out the line in /sbin/rc.boot that activates /dev/hd6.Search for
   hd6.
 o Disable use of hd6 at IPL either through SMIT or using -
       chps -a 'n' hd6.
 o Rebuild the boot logical volume image with -
       bosboot -d/dev/hdisk# -a
   (where # is the boot disk number on the machine - usually 0).
 o Reboot the system using -
       shutdown -Fr
 o Remove the old hd6 paging space through SMIT or using -
       rmps hd6
 o Create a new paging space of the correct size through SMIT or using -
       mkps -s'#' -a'' rootvg hdisk##
   (where # is the size of the new primary paging space in 4Mb partitions
         ## is the disk number where the primary paging space should be located
            - usually on hdisk0).
   If you use SMIT select activation on boot but not active now or you will
   not be able to do the next operation.
 o Rename this new paging space to be hd6 using -
       chlv -n hd6 paging##
   (where ## is the number of the paging space created - usually 00 if this
    is the first manually created paging space).
 o Edit out the reference to the old paging00 in /etc/swapspaces
 o Remove the comment from the "swapon" command in /sbin/rc.boot
 o Rebuild the boot logical volume image again as above.
 o Reboot the system using -
       shutdown -Fr

 These instructions are based on an append to the ISTHERE forum on IBMUNIX.
 I've modified them to a) remove typos b) provide AIX commands for all
 operations - you needn't use SMIT at all if you don't want to and c) provide
 a more orderly and definite series of instructions - the append was a bit
 conversational.

 From start to finish it took approx 12mins on a 320H - most of it is due to
 the two shutdowns.

 This method will also work on boxes with only 1 hard disk and therefore
 usually only one paging space, the primary one. Contrary to popular belief
 an RS/6000 will boot up without any paging space - no guarantees about
 running X and InfoExplorer though!

 Regards,
 Chris Thomas
======================================================================
>92236. A more colorfoul directory listing

Using this awk filter on a hft or aixterm will diplay executables, directories
and ordinary files in different colors.

#!/bin/awk -f colordir
#@(#) COLORDIR Version 1.0;  Doug Ranz Wednesday, July 01, 1992  09:28:06 EDT
#
#  Simple color directory listing program by John Duglosz
#
#  Modified By:  Doug Ranz Wednesday, July 01, 1992  09:28:06 EDT
#  Modified By:  afx       Friday,    July 03, 1992  14:58:00 EDT
#
#
#  Usage:        ls -F | cdir
#
#  Hint:         use a bsh/ksh function or a csh alias
#                For example in your ~/.kshrc file:  
#                lc () { 
#                       ls -F $* | colordir 
#                }
#
# [ = open squere bracket
# ] = close squere bracket
# | = vertical bar
#
function lastchar() { return substr($0,length(),1); }

# test code
#      { print $1 " ends in " lastchar(); }

BEGIN  {
       ESC="\033"                                       # define escape
       color["*"]= ESC "[32m";                          # executable: green
       color["/"]= ESC "[31m";                          # directory:  red
       color["normal"]= ESC "[37m" ESC "[11m";
}

       { print color[lastchar()] $0 color["normal"] }

# the end
======================================================================
>92239. HOTW: Is the 'pg' (page) command too plain?

 The 'pg' command seems to have many underutilized options.  These
 options permit you to alter the behaviour and appearance.  I hide my
 favourite options 'pg -secp" Page: %d. "  options using ksh aliasing.

 Example:  pg -c

           Moves the cursor home and clears the screen before painting
           each screen/page.

 Example:  pg -e

           Tired of 'pg' pausing on the last screen?  This option
           causes 'pg' to exit after painting the last screen.

 Example:  pg -f

           Do not wrap (long) lines.

 Example:  pg -p" Page: %d "

           Changes the dull ":" prompt to the something a bit
           fancier that displays the page number.

 Example:  pg -s

           All messages and prompts will be highlighted.
           (Using the terminfo database entry for your terminal.)

 Example:  pg +/RegularExpression/

           Starts at the first line matched by RegularExpression.

 Within the 'pg' program you have a variety of search and scrolling
 options.  Forward one line, forward one-half screen, backward one-half
 screen, etc ... checkout the man page for more details

dr

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

-- 
Andreas Siegert / Postmaster   IBM Deutschland GmbH   |   Never grep a yacc
AIX Field Support Center       Pocci Strasse 11       |   by the i-node!
afx@ibm.de                     D-8000 Muenchen 2      |   Opinions are my own,
siegert@munivm4.vnet.ibm.com   Voice: (49)-(89)-7670-509  not IBM's.