Chapter 14 of 14
Deliver the beacon report
You have a file that contains a program. The filesystem controls who may execute the file. Inside the file, the module header tells OS-9 what it can load. Those are two different checks. Give the file execute permission and run it from its full path.
Choose the destination
attr /h1/beacon e
/h1/beacon
The program prints beacon report and the shell prompt returns. Now run it again. This time let the shell create a fresh file named report at the root of your practice HD1.
/h1/beacon >/h1/report
list /h1/report
The first command goes straight back to the prompt. The second displays the two words. The file /h1/report contains the message from the module. Your shell procedure from the beginning of the book lives one directory deeper under /h1/station/report.
Trace one line through the system
| Stage | On the terminal run | On the file run |
|---|---|---|
| Shell+ prepares the child | Standard output refers to the terminal. | The shell opens the named output file and supplies it as standard output. |
| The module begins | A new process starts at the entry offset in Beacon's header. | The same module, entry point and instructions are used. |
| Beacon calls I$WritLn | A holds 1, X points to the text and Y holds 14. | A, X's meaning and the byte count are the same. |
| OS-9 resolves path 1 | The path leads through the character file manager and terminal driver. | The path leads through RBF and the HD1 disk driver. |
| Beacon finishes | F$Exit returns the status to its parent shell. | The process exits and the saved file can be opened independently. |
The number 1 in the program identifies a slot in that process's path table. It does not permanently mean screen or disk. That small indirection explains why a program written by someone who never saw your practice disk can still write a file there.
Catch the error at the right layer
With /h1/report still on the practice disk, enter exactly the same redirection and then read the existing file.
/h1/beacon >/h1/report
list /h1/report
The repeated create reports ERROR #218. The listing still prints beacon report. The shell needed to open the destination before launching the child. When that open failed, no Beacon instruction ran. A program's carry check after I$WritLn handles a different case, a failure after a process has started and requested a write.
Give the line to another program
Can you display only matching lines without changing any source or creating another report on disk? Predict what grep will receive, then try:
/h1/beacon ! grep report
The guest's GREP displayed : beacon report. The leading punctuation belongs to the filter's display of the match. The module supplied the same line it wrote to disk. In this run the shell connected Beacon's output to a pipe and the filter read the other end. The filter still had its own output path to the terminal.
You can now explain a trip that begins at a key and ends in a disk sector. Shell+ interprets the command, opens a path and starts a process. The process requests a service. A file manager interprets that request for this kind of device, and its driver transfers the bytes. Back at Shell+, list is a different process opening that same file for reading. For another way to make an OS-9 program take part in this arrangement, try the period C compiler.