Shawn M. Gordon

If your computer experience background is anything like mine, then you are already familiar with MPE and know DOS good enough to tell other people what to do, but you aren’t sure if UNIX is an operating system or a court servitor. So I recently took it upon myself to learn UNIX and come up with enough meaningful equivalencies to the operating systems I was familiar with to make it easier. What I plan to do is share some of that experience with you and hopefully make your life a little easier if you have to deal with UNIX in the near future.

One of the interesting things about UNIX is that unlike most operating systems, it wasn’t originally developed to be sold or to sell hardware. It was written in the C language by one of the fathers of the C language, and the source code use to be given away with the operating system. Now most of these early installations were colleges and you can imagine what could happen to an operating system where the source code was readily available. So UNIX evolved to suit peoples needs as they arose, this is also why UNIX is rich with bizarre programs and commands, such as awk, grep, yacc and troff to name a few. Since UNIX is quickly becoming the industry standard for open systems it is now subject to standards committees, this doesn’t keep all the different flavors of UNIX from being different enough to cause confusion however. If the OSF (Open Software Foundation) of which HP is a part has their way (and it looks like they will), then the OSF compliant version of UNIX will soon be available and be based mostly on IBM’s implementation of UNIX known as AIX.

Since some commands or switches to commands are only available under certain shells in UNIX (more on shells later) I’m not going to always point out every valid permutation for each command under each shell since that would get rather tedious. Rather, if you find that you want to use a command check with your UNIX documentation for the specifics.

Getting Started

Logging on to a PC typically just requires turning it on. Logging on to the HP 3000 requires hitting return to get that familiar : prompt and then typing ‘HELLO SESS,USER.ACCT’, which will then do any MPE level password checking and then execute any logon UDC’s. On the UNIX system when you hit return you are usually presented with a ‘login ‘ prompt at which time you can enter your user name, which is typically your name or whatever standard has been established at the company. At this point you will be prompted for a password if you have one. UNIX has a file called ‘.profile’ that acts very like an option logon UDC or an AUTOEXEC.BAT file in that it contains a list of commands that are to be executed when you log on, more on that in a minute. The UNIX prompt is configurable, like DOS and MPE/XL (MPE/iX), but typically defaults to


Any filename that starts with a ‘.’ is sort of hidden in that it doesn’t display in the standard UNIX ‘listf’ mode, but is displayable in certain ‘listf’ modes. The .profile file should contain many of the things that you would put in an AUTOEXEC.BAT file or OPTION LOGON UDC, like PATH= (similar to HPPATH), customized prompt, alias commands if you are using a shell that supports them (alias commands are like command files, UDC’s or DOS .BAT files), the shell you wish to use and your default editor, to name a few.

Since there are actually 3 different popular shells in UNIX it makes it difficult to be specific about syntax and options at logon. You can think of a shell as something like MPEX by VESOFT which gives you different command capabilities than MPE. I will cover the different types of shells later in this paper.

When you want to log off of a PC you turn it off, when you want to log off of the HP you type BYE at the : prompt or get aborted by someone. When you want to log off of a UNIX system you type ‘logout’, or ‘exit or hit <ctrl> D. Under some shells there is even a file that you can have execute at logout time called .logout.

Once your on the system sometimes you will want to find out how you are logged on. On MPE you can type SHOWME from the colon prompt, on UNIX I have seen both ‘who’ and ‘who am i’, who will show everyone that is on the system like MPE’s SHOWJOB command, and the who am i will show just you. You can also see your process tree, that is any child process or printing event or shell that is associated with your sign on. On the spectrum class MPE machines you can use the SHOWPROC command, on the classic MPE machines if you own MPEX you can use either SHOWTREE (for yourself) or SHOWPROC to show yourself or someone else. Under UNIX the command is ‘ps’, you can use this to show yourself (default) or to show all processes. This also shows you the process ID numbers so you can kill a child process (gruesome). There are several switches associated with this command to get different bits of information as well, but the scope of this paper doesn’t include describing the use of every command.

Another command that fits in with the ps command is ‘kill’. This command serves two purposes, one is to act like the MPE command ABORTJOB and kill the root process for a user so they are effectively logged off. The second use is similar to the MPEX command of the same name. It allows you to terminate a process in your process tree. Since under UNIX you can make any command execute in the background (more on this later) this gives you some facility for controlling them.


I was hoping to put this part off for awhile, but most of this paper relies on understanding at least the basic concept of what shells are and how they work. Those of you familiar with DOS may know that DOS is only a shell that overlays the CPU and allows you to interact with it. You could also run DR DOS or GEM or Windows or OS/2, these are all shells and they all have their own look and feel and command structure that is different, but they all run on the same computer. Some of them play with each other better than others. On the HP 3000 Classic series we had one operating system, MPE, and it was always there, you couldn’t run it again or run multiple copies of it or anything like that. Then MPEX from VESOFT came along and it was a shell on top of MPE, providing additional commands and functionality. This is a good example of a program playing nice with the OS. On the spectrum machines (read 900 series) they made the CI (command interpreter) a runnable program. You could run multiple copies under each other for various reasons. The folks at HP were really thinking ahead when they did this, they were gearing up towards having UNIX on the 900 series. So MPE/XL was a legitimate shell program now (as a matter of fact you can run either UNIX or MPE/XL on the same box now, both the 9000 and the 3000 spectrum class are the exact same processor).

This get’s us up to shells on UNIX. Now UNIX is the operating system, but to interact with it you will probably want to use a shell. There are 3 standard shells that come with UNIX and HP has one for HP-UX that is a visual mouse based one (like windows). The default shell is ‘sh’ and this is the ‘Bourne’ shell. This is probably the least powerful of all the shells, but you always know it’s going to be there. It doesn’t support the ‘alias’ command or a redo stack to name but two shortcomings, but it is the fundamental UNIX shell. The next shell is ‘ksh’ the ‘Korn’ shell, I like this one best because it seems to have all the features I want while not getting to cryptic. This shell is typically available as well, and seems to be a good end-user shell. The last one is ‘csh’ the ‘C’ shell, this one is probably the best shell for programmers that really want to be able to customize their environment. It supports a lot of C language functions right from the shell which makes it very powerful.

So here is one of the first things you can put into your login .profile file, the specification of which shell you want to run at login time.

File Structure

The file system under UNIX is actually very similar to DOS, but I am not going to assume that you understand the DOS file system so I will explain how they are similar. As you may or may not know, on MPE, files are very definitely described animals, they have a record length and a file limit that sets a cap on the number of records that can be entered and they don’t let you change this without building a whole new file and copying the records into it. Since UNIX is so tightly coupled with the C language it isn’t surprising that the I/O facility in C would seem so strange to us MPE types. The reason is because UNIX keeps files in a free form format that sort of goes on forever or until you run out of disc space, whichever comes first. It is just a byte stream of data that has a record separator between each record in the file. If you want fixed length records then you better pad spaces in it under UNIX. This means that your files will never fill up though.

While we are on the subject of files I should mention how UNIX handles file access restrictions. Under MPE you can specify these types of attributes for each file:


    L = LOCK (allows opening with dynamic locking option)

      A = APPEND (implicitly specifies L also)

        W = WRITE (implicitly specifies A and L also)

          X = EXECUTE

          Each of these attributes can be specified for a different access level, specified as follows:ANY = Any user

            AC = Member of this account only

              GU = Member of this group only

                AL = Account librarian user only

                  GL = Group librarian user only

                    CR = Creating user onlyThe command that would be used to modify a files access attributes is ALTSEC, or you would specify the ACCESS parameters at build time. Under UNIX you are able to specify (R)ead (W)rite and e(X)ecute access for three different levels. Owner (CR) the creator of the file, group (GU) someone who is logged into the directory or a member of the directory that the file resides in, and world (ANY) this would be anyone on the system. The file attributes can be changed with the ‘chmod’ command, each of the combinations can be described in a bit mask that converts to a decimal number that can then be used in the chmod command, but that is getting a little more advanced.

                    The creator or owner of a file can only be set in MPE when you build the file or when you rename or copy it. If you happen to own MPEX you can use the ALTFILE command to alter the files creator. UNIX will allow you to modify the creator of a file with the ‘chown’ command, but you must either be the files creator or have system supervisor capability, which is comparable to having SM capability under MPE.

                    By now you are probably wondering how to purge a file on a UNIX system. This simple task gave a very frustrating 5 minutes, let me tell you. The command to purge a file isn’t purge or erase or del or delete, it’s ‘rm’ for remove. There are switches you can specify to have it prompt you if you want to delete the record or to recursively delete the files, which means it will go into each sub-directory and get rid of each file in them too, pretty handy switch. You can even do sort of a fake purge by using the ‘-t’ switch which will test the purge but not actually do it, this is to see if you have access to the files.

                    Since I am going to cover directory structure a little later I am only going to go over the specifics of the file naming conventions. Under MPE your file name is limited to 8 characters, must start with an alphabetic character and can contain no special characters. It can contain numerics, but they can’t be the first character. Under DOS you are limited to an eight character file name followed by a three character extension, this extension is important in that it says what kind of file it is. UNIX systems vary in terms of the number of characters they allow, from 14 to 256. What’s interesting is that file extensions are completely ignored by UNIX and in fact don’t actually exist as far as it’s concerned. If I had a file called ‘shawn.doc’ it wouldn’t be considered to be a five character file name followed by a three character extension, but rather it would be seen as a nine character filename since the ‘.’ would be considered to be part of the filename. You will find that there are some standard conventions for what appear to be file extensions, like C source code is always followed by ‘.c’ an header files are ‘.h’, but that is enforced by the program, not by the operating system. As a matter of fact a command compressed archive file will be seen as ‘file.tar.Z’. It is also important to note that UNIX is case sensitive when it comes to file names, so ‘myfile’ and ‘Myfile’ and ‘MYFILE’ would be seen as three different files.

                    Now that you have named some files you will probably want to list them out. When you want to see what files are on your system in DOS you issue the DIR command followed by whatever wildcards you want to use. Under MPE you have the LISTF command followed by a file set then a mode that will describe the output format that you wish to see. The different modes provide different types of information to view. Under UNIX you have the ‘ls’ command that will also take filesets with wildcards and modes, the modes are actually called “switches”, switches are used for almost every command under UNIX to describe the different options you want the command to process. These switches can be specified using the ‘-‘ sign, for anyone that has used a file archiver under DOS this should be familiar. You don’t however have to specify a separate ‘-‘ for each switch. For example under MPE the most common listf mode would be executed by the following.

                    :LISTF M@.GROUP,2

                    The similar command under UNIX can be described either of 2 ways

                    $ls -l -a m*


                    $ls -la m*

                    The ‘l’ switch tells the ‘ls’ command to list the files in a long format and the ‘a’ switch tells it to list all files, this will include the ‘.’ files that I mentioned earlier were sort of hidden. They will only be displayed if you specify the ‘a’ switch on the ‘ls’ command. See example one for the output.

                    Directory Structure

                    MPE uses a simple 3 tier directory structure that comprises ACCOUNT, GROUP and the FILE itself. This doesn’t provide for a whole lot of flexibility since MPE doesn’t even allow for a file extension, unless you want to think of GROUP as being the file extension. A simple analogy would be to think of a file cabinet as an ACCOUNT and the drawers in the cabinet as the GROUPS and of course the contents of each drawer are the FILES. While you would use the BUILD command to create new files, you would use the NEWACCT (SM capability required) or NEWGROUP commands to create accounts or groups. The associated commands ALTACCT and ALTGROUP allow you to modify various attributes of accounts and groups that you might have left off when building them originally. Refer to example two to see how the two directory structures differ.

                    Under DOS or UNIX you can think of the disk drive prompt (DOS) or root (UNIX) as the ACCOUNT, this would mean that UNIX only allows one account since directories can span disk drives and it is transparent to the user. You can then create directories (similar to GROUPS) with the ‘mkdir’ command. You can keep creating directories under directories until you get hopelessly lost if you want to, the actual limit to nesting, I believe, has more to do with the limitation on command length than anything else.

                    Now that we have built a few directories, let’s purge them. On MPE we would issue PURGEGROUP or PURGEACCT, on UNIX it would be ‘rmdir’ for ‘remove directory’. If you are familiar with DOS you will notice that UNIX uses the forward slash ‘/’ to signify the root and to separate directories, i.e., ‘/etc/bin/myprog’ would run the program that was called ‘myprog’ and was located in the ‘bin’ directory which was in the ‘etc’ directory. DOS on the other hand use’s the disk drive letter to signify the root directory and uses the back slash ‘\’ to separate directories. Just to throw a buzz phrase out, the UNIX directory structure is referred to as a ‘single inverted tree directory structure’.

                    Batch or Background Process’s

                    Under MPE when you have a long task that needs to run or a series of tasks that you want to execute, you typically will create a job stream and submit it to the CPU for execution. This will introduce the file to the MPE batch facility and sequentially execute the commands in your file as long as they are valid. If you just want to run a single program you can either program your own shell that will call the ‘CREATE’ intrinsic and execute the program in the background or use MPEX to execute the program in the background. If you wanted to specify that a job was to start at a certain time on a certain date you could use the stream scheduling parameters that MPE provides such as AT=, IN= etc.

                    UNIX provides these same type of facilities fortunately. There are actually several ways that you can access the batch or background facility. The first and easiest is to append ‘&’ (ampersand) to the end of the command that you execute. This will immediately cause the process to execute in the background as a child process to your session, leaving your terminal free to do other tasks.

                    A neat thing about UNIX is that it has demon’s, actually it is spelled daemon. Under UNIX a daemon is a process that is designed to perform a particular task or control a particular device without requiring the intervention of a human operator. What does this have to do with batch processes? The most typical daemon is cron, the cron daemon is a scheduling process. Anything that you want to happen on a regular basis should be set up in the crontab file which cron will read and execute. Cron wakes up and reads crontab once each minute and if the time is met or passed it will then execute the commands. So UNIX comes with a free batch scheduler.

                    The next command that works with cron is ‘at’. This works very much like MPE’s STREAM facility when used with the AT or IN parameters. You can specify a command or a program or series of commands. If you give it a file name it will read the file and execute the commands contained in it, just like an MPE job stream. You can also use the ‘at’ command with the -l switch to list the jobs ‘at’ is scheduled to execute for you or the -r switch to remove an ‘at’ job.

                    RUNNING PROGRAMS

                    We are given a few fancy ways to run programs under MPE, we have entry points, parms and info strings that can be used, as long as the program has been written to handle them. Last year we were blessed with I/O redirection on MPE/XL and under MPEX (more on that in a minute), but except for SORT/3000 we typically write a program to do all aspects of a project.

                    UNIX has taken a very different philosophy and it seems to be based on the C language. The neat thing in C that people try to teach is the tool box approach, basically this means to write your code or programs at a fundamental level so parts can be re-used easily in other applications. Some good examples would be a sort routine, word counting, spell checking, date and time conversions, etc. So what has happened on UNIX is that you have a whole bunch of these little single purpose programs and when you run a program you will probably do some I/O redirection and piping. I suppose I should explain what those things are first, let me show you an example of a command and then explain it.

                    $ (ls -l /etc | wc -l) > list.out

                    Ok, from left to right, first off we are doing a listf of all the files in the ‘etc’ directory in the long format so it shows all the files that start with a ‘.’. Next the output of this is piped with the use of the ‘|’ symbol into the ‘wc’ program. This is a word count program and the ‘-l’ switch means count the lines in the file. The output of all this is sent to the file called ‘list.out’ by use of the ‘>’ symbol. This will result in a file that contains a count of how many files are in the ‘etc’ directory. Pipes redirect the output (stdlist) of one or more programs into the input (stdin) of another program. The I/O redirection symbols send the output to a command or file, or will get the input from a file and send it to the program. > redirects output, >> appends the output, < gets the input from a source.

                    I routinely use I/O redirection in MPEX with DBSCHEMA to create data bases, example:


                    This uses the file MYFILE.SCHEMA as input to the program DBSCHEMA. Pretty neat huh?

                    You can build command files or UDC files to execute a series of commands that you want to be able to re-use easily on MPE, and you can create batch files under DOS for the same purpose. In UNIX they are called shell scripts, but they serve the same purpose. There is another neat thing along this line and it is called the ‘alias’. Alias commands are only available under the Korn and C shells, not under the Bourne shell. This allows you to define a command to mean something else. So if you wanted to use the listf command instead of typing ls -la all the time you could say ‘alias listf ls -la’. This is definitely a nice thing to have. By the way the alias command was just added to MPEX in case you were wondering.


                    On the HP 3000 we have always been fortunate(?) that EDIT/3000 was included with the operating system. This gave us a fairly powerful editor that we could always count on being there. As time went on we found some nice editors in the CSL like QUAD and FED, and eventually some nice editors that were sold on the open market like Qedit and Speededit. Under UNIX there is a dizzying number of difficult to use and cryptic editors. You will find that your standard UNIX enthusiast will swear by ‘vi’ or ‘ed’ or ’emacs’, but I found them completely non-intuitive and confusing.

                    I will say, that emacs looks the most promising to learn so I think I will spend my time with that one, unfortunately the editor you are most likely to run into is ‘ed’ or ‘vi’. vi is actually a shell to ‘ed’, it gives you a visual editing environment to work in which is much better than what ‘ed’ has to offer on it’s own. There is one more that I saw called ‘sed’, now sed is known as a ‘stream editor’. It is a non-interactive editor, so you can put together a string of edit commands to apply to a file or set of files and then fire off sed. To make this really useful you would probably want to execute the command in the background by using the & sign as mentioned earlier. I would be remise if I didn’t mention the one other editor that came with my UNIX system, it is known as ‘elvis’ and it is a clone of the ‘vi’ and ‘ex’ editors that usually come with UNIX.

                    While I am still on the subject of editors and text their is another handy little utility called ‘nroff’. nroff is a text formatting program that is designed to format text to a screen or a monospaced printer. It’s related command is ‘troff’ which is for creating typeset quality output to a postscript printer. The only thing that I have really seen that comes close to being the same type of program on the HP is Prose from Robelle.

                    Now that I brought up printing you may be asking yourself how you get something to print on a UNIX system. Typically on the HP if you want to print a text file you would pull it into your favorite editor and then list the file off-line to the line printer. Or you may use the FCOPY program to send the file to the line printer. Once the file is in the spooler you can use the SHOWOUT command to see the state of the file i.e., printing, waiting, deferred etc. If you wanted to stop it from printing you could execute the STOPSPOOL command and then issue the DELETESPOOLFILE command if you wanted to get rid of the file altogether. On UNIX you can say ‘lp filename’ to print a file, ‘lpstat’ to show the status of the file sent to the spooler and ‘cancel’ to stop and kill a file that is printing.

                    What if you wanted to just view a file instead of printing it? Under MPE/XL or MPEX you can use the ‘PRINT’ command, however if you are under MPE/V or earlier you will have to use the FCOPY program and direct it’s output to your screen by leaving the ‘TO=’ parameter blank, or by using the MPEX PRINT command. UNIX gives you the ‘cat’ command, which let’s you say ‘cat filename’ and it will blindly display the file on your terminal until it reach’s the end, rather like the ‘TYPE’ command under DOS. Some shells offer the ‘more’ command, which will prompt you every time it fills a screen full of data, I even have an enhanced version of ‘more’ called ‘less’.


                    To be completely accurate I will quote from a letter that I received from HP. “The IEEE P1003 group, accredited by ANSI, was chartered in 1988 to specify a Portable Operating System Interface (POSIX) standard. Their goal was to specify the functions and services a standardized operating system must support, as well as the application programming interfaces to these services.”

                    So what does this mean? It means that a standard programming interface from the C programming language to the POSIX shell is implemented in what is called P1003.1, POSIX.1 or more commonly as POSIX dot one. HP plans to release this set of functionality in it’s initial release of POSIX for the HP 3000 and the user shell (POSIX dot two) in the next release. The user shell will enable you to interact with the POSIX environment straight from the operating system without having to write a program. As I understand it you will have to pay for the user shell part, but they hope to keep it under 15k.

                    The potentially very neat thing about this is that any application that is written to be POSIX compliant (obeys all the rules of POSIX), should in theory run on any other computer that has POSIX. Since POSIX makes a standard of the screen interface calls, file system I/O, and network services, to name a few, it should make it very simple to port applications around. I see the biggest hang up in converting for the various DBMS packages that are available, but here again we are lucky, since SQL is a standard interface for querying a relational database you might be ok there too.

                    Now the really interesting thing is going to be how MPE and POSIX are going to coexist on the same machine accessing each others files. As we discussed earlier they have radically different file and directory structures. HP tells us that applications written for either environment will be able to access the other with no problem. Existing applications will assume MPE conventions as defaults for commands and intrinsics, but the POSIX C interface will assume POSIX rules.

                    According to the roll out schedule that HP as quoted, POSIX dot one could very well be out by the time you read this, and POSIX dot two should definitely be out by the end of 1992. This could make porting off the 3000 to a 9000 just to get applications a thing of the past.


                    Example 1.

                    (MPE LISTF command output)

                    :LISTF M@,2

                    ACCOUNT=  PROD        GROUP=  PUB

                    FILENAME  CODE  ------------LOGICAL RECORD-----------  ----SPACE----                   SIZE  TYP        EOF      LIMIT R/B  SECTORS #X MX

                    MONTHEND           72B  FA         227        227   7       68 12 12 MYUSL     USL     128W  FB         147       1023   1      128  2 16

                    (UNIX ls -la command output)

                    $ ls -la m*

                    -rwx------  1     shawn   users   539    Dec 12  11:19  make -rw-rw-rw-  5     shawn   users   643    Nov 22  14:22  mass.c -rwxrwxrwx  2     shawn   users   25     Dec 10  10:30  mass  

                    Example 2.

                    (MPE directory structure)

                    Account:                        PROD                                  |             ------------------------------------------             |                    |                   | Groups:    PUB                  DATA                JOB             |                    |                   |         ---------            ---------           --------- Files:  -SL                  -INVOICES           -DAILY         -FILE2               -APINV              -WEEKLY

                    (UNIX directory Structure)

                    Root                                    /                                         |                     -------------------------------------------                     |           |                |            | Directories         etc/      lib/              usr/         bin/                     |                            |             -----------------             ----------------            |                |             |        |     |           conf/           mail/         shawn/    bin/  lib/

                    Summary of Commands  

                    MPE                MPE/XL               MPEX               UNIX              DOS

                    HELLO              HELLO                N/A                login             N/A BYE                BYE                  EXIT               exit              N/A LISTF ,2           LISTF ,2             LISTF ,2           ls -laF           dir N/A                N/A                  PRINT ;SEARCH=     grep              find N/A                SHOWPROC JOB=@       SHOWPROC @.@       ps -ef            N/A SHOWJOB JOB=@S     SHOWJOB JOB=@S                          who               N/A SLEEPER            MasterOP             STREMX             cron              N/A STREAM ;AT=        STREAM ;AT=          N/A                at                N/A TELL               TELL                 TELL               write             N/A PURGE              PURGE                YESPURGE           rm -i             del SHOWME             SHOWME               N/A                who am i          N/A FREE5              DISCFREE E           N/A                bdf               chkdsk N/A                N/A                  RUN ;GOON          unixcmd &         N/A N/A                N/A                  GOD.PUB.VESOFT     su                N/A ALTSEC             ALTSEC               ALTSEC             chmod             attrib N/A                CHGROUP              CHLOGON            cd                cd FCOPY ;COMPARE     FCOPY ;COMPARE       N/A                diff              comp NEWGROUP           NEWGROUP             N/A                mkdir             md PURGEGROUP         PURGEGROUP           N/A                rmdir             rd FCOPY              PRINT                PRINT              lp                print N/A                lzw/zip              N/A                compress          pkzip N/A                lzw/unzip            N/A                uncompress        pkunzip N/A                HPPATH               HPPATH             path              path N/A                ECHO                 ECHO               echo              echo RENAME             RENAME               RENAME             mv                ren N/A                RUN CI.PUB.SYS       CI.PUB.VESOFT      sh/csh/ksh        command STORE              STORE                MPEXSTORE          tar               backup RESTORE            RESTORE              RESTORE            tar               restore N/A                N/A                  ALTFILE ;CREATOR   chown             N/A