HP30003k Associates LogoHP3000/HP 3000 FAQ

Last Updated: Thursday, February 01, 2007 02:38 PM

HP3000 FAQ

HPe3000 FAQ

HP 3000 FAQ

Using the POSIX Shell

6.12. Using the POSIX Shell

6.12.1. Make sure you have that .profile set up correctly

The control keys don't seem to be registering with the shell. This is saying that ^Y should be able to interrupt a program. And ^@ should be able to stop input. But it's being ignored. Trying to set eof to ^D doesn't work either.

Make sure you have the following in your .profile:

# enable ^y

(1) The "SH" UDC sets your CWD to !hphgroup.!hpacct regardless of where you
    are, and won't work if you have no home group.  Yuck.  I prefer to set
    it to !hpgroup.!hpacct.
(2) As noted previously, "man" is broken, so "export MANPATH='/usr/man'"
(3) better check TERM if you change /etc/profile

Chris Ransom (chris@quests.com) and I had an offline discussion about vi, cursor keys, and curses in general; this led to the annoying behavior of man, more, etc., enabling the TransmitFunctions terminal configuration and leaving it that way afterward (annoying when you don't expect it). The terminfo entry for hp2392a includes a reset sequence but it is unused or uncalled (curses!). Then Chris sent this to me which I think is valuable enough to share:

On Thu, 08 Dec 94 14:36:21 PDT you said:
]I figured it out. This seems to actually work. I took a tip from DOS prompt
]programming and changed my prompt string to contain the escape sequence:
]   export PS1="^[&s0A"\$PWD$
]And, believe it or not, vi is smart enough to re-enable xmit fkeys if you
]escape to the shell and return to vi. This also solves problems with "more"
]screwing up your terminal, etc...

I would recommend using "hp2392a" since it is a more complete description of a HP terminal than "hp".

Anyway, I use VI as my editor-of-choice on 5.0. You need an ".exrc" file in your home directory (for example /CHRIS/PUB/.exrc). It should contain map statements to translate your cursor keys into the VI directional commands. For example:

   map ESC-A  k
   map ESC-D  h
   map ESC-C  l
   map ESC-B  j

Where "ESC-A" is actually escape+A in the .exrc file (hard to display here).

I'm fairly certain that an HP-UX .exrc file will work fine if copied over to MPE/iX.

As Mark Klein points out, you need to have "Transmit Function Keys" enabled for your terminal. This is enabled automatically by curses(?) when vi is run. Setting your system's timezone value

Also in the /etc/profile, you need to set the global timezone (TZ) variable. For example,

export TZ=EST5EDT

for Eastern US timezone, Eastern daylight time.

6.12.2. Creating a link to a tape drive from the shell

To make a device link from the shell, try: mknod /dev/tape c 0 7. 7 is the LDEV number of your tape.

6.12.3. Some MPE commands and their POSIX equivalents

(Thanks to Chris Rice From the 4.5 class on the original list - now expanded (thanks Jeff Vance) to include new 5.0 commands :)

ABORTJOB        kill
ALTACCT         chmod
ALTGROUP        chmod
ALTFILE         chown
ALTSEC          chmod
BYE             exit
CALC            expr, bc
CCXL            c89
CCXLLK          c89
CHGROUP         cd
CHDIR           cd
CI              sh
CI              callci
COPY            cp
DISALLOW        chmod
DO              r
ECHO            echo
EDITOR          vi
ELSE            else
ELSEIF          else if
ENDIF           fi
ENDWHILE        done
EXIT            exit
FCOPY           cp, dd, lp
FILE            ln
HELP            help, man
HPDESK          mailx
HPSEARCH        grep
IF              if
LINK            c89
LISTACCT        ls -l
LISTEQ          ls -l
LISTFILE        ls
LISTFILE;name=  find
LISTGROUP       ls -l
LISTREDO        history
NEWACCT         mkdir
NEWDIR          mkdir
NEWLINK         ln -s
NEWGROUP        mkdir
PRINT           more, cat
PURGE           rm
PURGEACCT       rmdir, rm
PURGEDIR        rmdir, rm
PURGELINK       rm
PURGEGROUP      rmdir, rm
REDO            r
RELEASE         chmod 777
RENAME          mv
REPORT,DISKUSE  du, df, find
RESTORE         tar, cpio, pax
RETURN          break ??
SECURE          chmod
SET             set
SETDUMP         set -x
SETJCW          =
SETMSG          mesg
SETVAR          =
SHOWJCW         echo
SHOWJOB         ps, who
SHOWPROC              ps
SHOWME          who am I, pwd, uname
SHOWTIME        date
SHOWVAR @       set
STORE           tar, cpio, pax
STREAM          at, batch, bg, crontab
TELL            talk, write, mailx
WARN            talk, write, mailx, wall
XEQ             . ??

I see two meanings for the FILE command: 1) Used to convert between different file types. This has no meaning in the POSIX context because the POSIX context really only understands one filetype - "bytestream". 2) Used to associate one filesystem name to another filesystem name. This can be done with the link (ln) command.



(note: this will place an actual file on the drive, e.g. a permanent file equation so to speak. This is Posix symbolic linking of files.)

There is no reason you have to execute these commands from the posix shell. E.g., LS.HPBIN.SYS "-al" works just fine from the CI; same as: "ls -al" does from the Posix shell.

banner.hpbin.sys ":^)"


WELCOME                 vi /etc/motd
HELLO;TERM=             export TERM=
CCXLLK is sort of       make
option logon;system     /etc/profile
option logon            ./.profile
SET HPPATH=             export PATH=

And I love the "hot" program replacement in the shell. Who cares if people are running the program. "rm program". "mv newprog program" new version is in.

Take care with this last part. I did the following:

FILENAME  CODE  ------------LOGICAL RECORD-----------
                  SIZE  TYP        EOF      LIMIT R/B
NEWFILE             1B  BAL          9       1024   1
OLDFILE            80B  FA           0       1023   3


 NEWFILE             1B  BAL          9       1024   1


 lrwxrwxrwx   1 MANAGER.SYS TELAMON 9 May 23 13:43 ./NEWFILE -> ./OLDFILE

Notice that the PURGE deleted _OLDFILE_, not NEWFILE, although the link of NEWFILE -> OLDFILE still remained. If you build a link using LN.HPBIN.SYS, you'll have to get rid of it using RM.HPBIN.SYS, _not_ PURGE.

Kevin Cooper - HP Commercial Systems Division notes:

This is a distinction between PURGE and PURGELINK in the CI, and is an important concept for MPE users to understand. If you :PURGE a link, it is like saying :PURGE *FILE, where FILE references a previous file equation. The file on the right side of the file equation will be purged.

If you want to get rid of the link, use :PURGELINK NEWFILE in the CI. At the 1994 Interex in Denver, I did a paper called "A System Manager's Look at MPE/iX 5.0", which covered some MPE/POSIX topics like this. I tried to explain POSIX things in MPE/iX terms. I wrote it for someone who is trying to understand POSIX-style concepts from an MPE/iX knowledge base. It is paper #8008 in the proceedings from that conference.

6.12.4. POSIX migration issues

I don't known if this qualifies but I've spent the last couple of months porting a server generated by snacc on a unix box to IX/posix and ran up against the following on the posix side:

   doesn't seem to read CCOPTS
   resolved by using make -f Makefile.prod and -f Makefile.debug

   it either truncates the info (or at least the -D)
   resolved by include "ccopts.h" as first line of each .c

   executes each statement seperately, i.e.:
   -cd ber_lib;make
   causes it to go into an infinite loop
   resolved by creating command files

   Files uploaded as ascii by reflections can not be extended.  If
   shorted and downloaded, the file is padded out to it's original
   size with nulls.  Use :!rm [file] before :w

   Pet peeve, doesn't understand TERM=hp curser keys.

   hangs on even small files.  Note the files are extracted from tar.Z
        but compiled fine.

lp, lpr:
   don't exist.  /dev/lp can't be seen.  Add a fileq before
   entering posix and callci print $file > *lp

   Isn't available.  Use :eod.

   Will not abort the program if open TCP session (but will abort
   the listening socket).  Or maybe I just didn't wait long enought.

   open - can not open an MPE file.  Replaced with FOPEN, FREAD, FWRITE.
   fork - can not have database open.  Close it and reopen in both
        parent and child.
   offsetof - wouldn't compile, gave up and used
        (char*)&struct->mbr - (char*)struct
   setsockopt - all the normal defines, but some not implemented and
        return error.  Ifdef it out.

good news:
   Copylefted software that built okay:  gzip, patch, flex, bison, p2c,
   shar, snacc.
   SETDUMP before entering posix will still produce trace.
   Putting the executable into an MPE visible directory with an MPE
   name and it can be run from MPE with :DEBUG but never tried with
   the forking version.

   LaserRom for MPE is way behind the LaserRom for UX, which was way
   behind InfoExplorer on AIX.  These beg for hyperlinks.  As error
   and ommisions are constantly being corrected, putting
   documentation on line should be considered.  And if have
   authentication, indexed error reports, and error report submission.

6.12.5. Porting tips for POSIX applications

I just got a nice little piece of info from MKS.

To make an alias for cc to c89, do the following:

  shell/ix> ln -s /SYS/HPBIN/C89 /bin/cc
  shell/ix> ln -s /etc/c89.ccg /etc/compiler.ccg

This makes cc a legitimate alias for c89 even inside make. I like it because it's one less change I need in the makefiles that come with Unix software.

When making mods to source code, the following two IFDEFs are the standards for identifying:

__GNUC__ GNU C Compiler

__hp3000s900 HP3000 Series 900 (i.e. MPE/iX)

For a detailed paper on porting issues in the MPE/iX POSIX environment, see Mark Bixby's paper at http://www.cccd.edu/~markb/porting.html. Mark is one of the most experienced "porters" of applications to MPE/iX and has ported many applications including BIND, Sendmail, Apache, and others..

6.12.6. Executing CI commands and system calls from POSIX apps

Bruce Toback (btoback@OPTC.COM) wrote: : The system() call actually uses the Posix CI, since it expects Posix- : syntax system commands. It's not a call to HPCICOMMAND, which would use : the MPE command interpreter.

Let me expound on Bruce's answer just a little bit. [We were talking about this today at the MPE Technical Roundtable at IPROF's.] When you compile and link a C program in the MPE CI environment, your program is bound to the 3000's "ANSI" C library. [I call it the ANSI C library, but it really is the non-POSIX C library that has always been part of XL.PUB.SYS.] This library was around long before we began the design of POSIX on MPE. So, the system() function was implemented as an interface to the HPCICOMMAND intrinsic. When we added POSIX to MPE, we didn't want existing programs to have to be re-written. So, the ANSI C library still calls the HPCICOMMAND intrinsic. The POSIX C library, /lib/libc.a, implements the system() function by invoking the POSIX shell. When you use c89 in the POSIX shell, your program is bound to the POSIX C library. The correct call in this case is:

nRval = system ("callci \"TELL #s383; Edward, send help!\r\"");

callci is the POSIX shell command for invoking the MPE CI. Any object file that wants to call the POSIX C functions must be linked with the POSIX C library, /lib/libc.a. Note that this library is an RL.

A couple of additional notes. A program built in the POSIX shell can be run from the MPE CI prompt. [Jeff Kell has a few cautions in this regard which he posted to this newsgroup.] You can also use the MPE CI to compile and link a program with the POSIX C library. You do the compile as you did in your example, but you use a different link command.

   ccxl tstsysmc,tstsysmo
   link from=tstsysmo;to=./TSYS2;rl=/lib/libc.a;cap=ph;posix;share

One final note, in your POSIX shell example you had the comment, (use linkedit to alter program capabilities to add ph) This is unnecessary. c89 from the POSIX shell always links programs with PH capability.

6.12.7. Correcting file permissions so various programs will work

As shipped, there are many file permission problems with files in the HFS directory (including many of the terminal configuration -terminfo- files required by various interactive applications.. like Lynx for one example. Also 'vi'. You might get error messages such as:

Unknown terminal "hp2392a".

To correct these;


  :hello manager.sys
  :xeq sh.hpbin.sys -L
  cd /usr/lib/terminfo/h
  chmod 555 *

Or perhaps more precisely;

As MANAGER.SYS enter the shell (have HPPXUDC.PUB.SYS set as the local UDC file!)

cd /usr/lib/terminfo

chmod +r *

cd h

chmod +r *

6.12.8. Where to find ported POSIX applications (and other HP3000 shareware)

www.3kassociates.com - follow the links to "public domain software". You'll find a CB page with links to known ported applications, shareware native hp3000 applications, and games.


Back to FAQ Index Back to 3k Home Page
HP3000-L FAQ Collection (c) 3k Associates, Inc. 1996-2006