HPlogo Using HP 3000 MPE/iX: Fundamental Skills Tutorial: HP 3000 MPE/iX Computer Systems > Chapter 7 Command Files

Lesson 1 Using Command Files

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

Lesson 1 presents creating and using command files.

  • what is a command file is

  • how to create and use a command file

  • command files that execute other command files

What is a command file?

A command file:

  • is a text file, just like any text file that you create

  • may contain MPE/iX commands, program file names, and the names of other command files

  • executes the commands, programs, or other command files that are named inside it

Creating and executing command files

At its simplest, a command file is an MPE/iX command that you shorten. For example, instead of typing in the whole command SHOWTIME, that you can use the editor to create a command file called ST that contains the command SHOWTIME. You save it and leave the editor. Every time that you enter STReturn at the system prompt, SHOWTIME executes.

Get into the editor. Create a one-line file. The only line that you need is SHOWTIME.

It will look like this on the screen:

   /ADD

        1    SHOWTIME

        2    //

   /KEEP ST

   /EXIT

You have a command file called ST.

Enter:

   STReturn

What happens on the screen?

Another example of a one-line command file is PR. It prints the last three lines of the file DOCUMENT to the terminal screen. (Of course, you would have difficulty if the file has fewer than three lines.)

Get into the editor now. Create a new file by doing the following:

     ADDReturn

     PRINT FILE=DOCUMENT;START=-3Return

     //Return

     KEEP PRReturn

Exit the editor.

Execute the command file PR by doing the following:

   PRReturn

You should see on the screen the last three lines of the file DOCUMENT that you created in module 3.

Suppose that you created a command file that has this one line:

   LISTFILE @.PUB

What would this command file do?

This command file would list all of the files in the PUB group of your account. If this file were to be kept as PUBLIST, look at how many keystrokes that you would save each time this command file was executed.

Create and execute this command file, PUBLIST.

Command files that execute other command files

One command file can call upon and execute another command file. The example below shows what that you might put in a command file named PS. It executes the command file PR and then executes the command file ST.

Try it. Create the file in the editor, just as it appears below.

   1   PR

   2   st

Save the file as PS and exit out of the editor.

To execute it, enter the following:

   PSReturn

Do you see the last three lines of the DOCUMENT file and the date and time on the screen?

NOTE: If an error message occurs while you are trying to execute a command file, check the contents of the file first for command line syntax errors.

Lesson 1 Exercises

  1. Create one command file called P5 that lists the last five commands in your command line history stack. Be sure that you have at least five commands in your command line history stack. Execute the command file P5.

  2. Use the editor to create a 10-line file. Save it as FOREST.

    Create a command file called PRF that prints the first four lines of the FOREST file to your screen. Execute it.

  3. Create a command file called CG that puts you into the OTHERGRP group of your account when executed. Execute it.

    1. Check to see if you were successful.

    2. Get back into your home group.

  4. Create a command file that executes any MPE/iX command that you know. Execute it.

  5. Create a command file that executes another MPE/iX command that you know. Execute it.

  6. Create a command file that executes the command file created in step 4 and the command file created in step 5. Execute it.

Feedback to webmaster