| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |

January 2005

Boosting Your e3000 Productivity

MPE for UNIX Users:
Examining File Content

By Robert Green, Robelle

Last month in Part 3 of our series, we looked at files. This month we learn how to look at file content. If you are a Unix person, the first thing you look for is more, and the MPE equivalent is Print:

Print filename

Print displays the lines of the file on $Stdlist, stopping every screenful and asking if you want more. You can answer Y or N. In Unix, you usually press Space for Yes or “go on,” but in MPE you usually press Enter.

Print is only useful for files of text data. For looking at binary data, the basic tool provided by MPE is Fcopy.

The main purpose of Fcopy is “file copy,” but it can also display binary data in Hex or Octal format and do some simple data selection. Fcopy is a subsystem, while Print was an MPE command. You enter the subsystem with the Fcopy command and it has its own commands. You exit the subsystem with the Exit command (some later subsystems used Quit as Unix started to influence MPE). Other subsystems of MPE include Editor and Sort.






Notice that when you enter Fcopy, the prompt character changes from Colon to Greater Than. This is typical – a Colon prompt always indicates that an MPE command is expected.

The first command displays each record of filename on $Stdlist as a hexadecimal dump and as a character dump (Char replaces nonprinting characters such as Carriage Return and Linefeed with Period to avoid disrupting your display).

The second command converts the record data to Octal instead of Hex. The third command, Exit, gets you back to MPE.

Fcopy introduces you to a couple of other MPE-isms. You use Control-Y to stop the listing; this is true for all MPE subsystems, but for MPE commands use the Break key if Control-Y does not work. The syntax of the Fcopy commands is different from that of MPE commands; unfortunately, this is true of most all MPE subsystems — they all have slightly different command syntax styles.

Fcopy also allows you to select specific records numbers, or records that have a specific text string at a given location. You append the Subset option to your copy task:


subset=”string”, column [,EXCLUDE]

But Fcopy cannot select on binary fields or look for multiple strings.

For complex text searches, the Unix user turns to grep, and MPE has grep in the Posix shell. To enter the shell, you type “sh.pub.sys”, which is an implied run on the “sh” program in the “pub” group of the “sys” account. When you are in the Posix shell, you must use Posix filenames, not MPE filenames. So sh.pub.sys would be /SYS/PUB/SH.

For looking at file contents, the Posix head and tail commands are very handy (show the start of a file or the end of it). Another MPE subsystem that can be used for examining text files is Editor.


/text filename

/find “string”

/list *


Notice that the prompt character is Slash, while Fcopy used Greater Than.

Editor has a fairly powerful set of search options. In this example, Find looks for the next line that contains the string at any location within the line. But to find all the lines that match, you must program the Find in a While loop.

MPE also has a wide variety of text tools from third-parties that you will likely want on your system, such as our own Qedit, an Editor replacement that also provides full-screen editing (see www.qedit.com).


/text filename

/list “string”


The Qedit commands are similar to Editor’s, but the default behavior is to treat any occurrence of a string as a request for all the lines that contain that string. Qedit borrows concepts from Fcopy and other tools. For example, you can display the selected lines in Hexadecimal if you wish: /list $hex $char 1/10

Or ignore case and only search certain columns on string matches: /List “enhancement” (Upshift 20/50)

Or search for up to 10 strings on a single command: /List “problem” or “bug” or “help”

Magnet is our method of choice for searching a group of files, because it is so fast. It is a part of Nuggets (aka Toolboxes), a package of MPE utilities written by Stan Sieler and friends, and sold by Lund. By default, Magnet lists the files with a filecode of zero (regular files) or 111 (Qedit files) in your logon group that contain at least one line with the target string. Use the -F option to specify filesets, the -C option to ignore case, -L to list lines that match, and -E to show Editor-style line numbers.

For example, to search the SRC group of the logon account for “fopen,” ignoring case, you would use the command :magnet “-f@.src fopen -c -l –e. (For more details on Magnet, see www.allegro.com/products/hp3000/toolboxes.html)

MPEX is a third-party tool from Vesoft that extends the MPE command shell to work on sets of many files, rather than just one file. It is very flexible and allows selections such as “files bigger than 1 GB and untouched in over a year.” MPEX allows you to select files based on searching text within the files:


MPEX also allows searching for lines containing alternate strings, or more than one string, or almost any search logic:




There are many more options (case-less, look for delimiters, look for a delimiter on the left only, etc.).

Database Files

What does it mean when you get the error below?

:print store01.db


The PRINT command failed. (CIERR 9080)

This means is that you tried to open a database file in user-mode. These are “privileged files” that can only be opened in Priv Mode. This restriction ensures the integrity of the database structure by forcing all access through system-approved tools or APIs.

Query is a database tool found on every HP 3000. It can do selection, but only works on databases, not disk files. A simple Query task would be:


>FIND order-detail.order-date GT 20040101


Query has numerous report formatting options, including sorting, level breaks, item formatting, etc. However, the output is intended for a printer, so most of the formatting options have that in mind. It is possible to redirect this output to a disk file, but Query was written before anyone asked for output to an Excel spreadsheet.

Suprtool is our third-party product (see www.suprtool.com) that is found on many HP 3000 systems; it works on both databases and disk files. Like Fcopy it can copy or print records using Char,hex dump, but it can do much, much more. It can do sophisticated selection and sort the records. For example, to select all the Open orders, sort them, eliminate duplicates, write them to a disk file for further processing, and print the fields of each selected entry, use:


>base orders.db

>get order-detail

>if order-date > “20040101” and order-status=”O”

>sort order-num

>dup none

>output opensel



Suprtool provides a Define and Item command to describe the record format of a file so that it can be treated like a database. Or to more accurately describe a database (i.e., define sub-fields, date fields, and decimal places). The output can go to the printer, or to a disc file, or to the database, or to an Excel spreadsheet, or to almost any other format of file.


Copyright The 3000 NewsWire. All rights reserved.