Reading and Writing Files from NetRexx

Cours reading and Writing Files from NetRexx, tutoriel & guide de travaux pratiques en pdf.

Tools Used During the Project

Regular CMS users may find the OPENVM SHELL a strange and confusing environment. Given the demands imposed by the business, taking the time to learn a new command environment may not be an option. Also the cost of the VM/ESA OpenEdition Shell and Utilities feature may be not an option for some VM installations.
During the project several tools were created to make the life of a CMS NetRexx and Java programmer easier. They provide the basic capabilities needed to develop and run Java and NetRexx programs. These tools are included in the sample program set for this book. See 2.7.1.5, ªDownload and Install the SG245148 Packageº on page 19 for information on obtaining the entire package of sample programs for your VM/ESA system.
The whole environment centers around the XEDIT, BFSLIST, NRC, and NRR commands.

XEDIT
XEDIT allows you to create and modify BFS files. It works just as in CMS, but you need a special parameter NAMETYPE BFS. To create or modify a file, simply type its BFS pathname, for example:
xedit /home/steve/myFirstProgram.nrx (nametype bfs
If you have the correct CP directory statement to set your current directory you do not need to specify your home directory explicitly. You can also set the current working directory with the OPENVM SET DIRECTORY command.

PROFILE XEDIT
Many programmers will have to modify their PROFILE XEDIT to make it work for BFS files.
First of all, the PROFILE XEDIT must be written in REXX to be able to edit BFS files.
Some XEDIT profiles analyze the fileid for which XEDIT is being called, for example:
Parse Arg fn ft fm ¢ ( ¢ options
However, when a user issues ªx AboutFrame.nrx (nametype bfs,º theParse Arg shown above yields:
fn = ²ABOUTFRA²
ft = ²²
fm = ²²
options=² NAMETYPE BFS ²
So there is no variable holding the BFS requested fileid.
As BFS fileids can even contain spaces or parentheses, a Parse Arg as shown above cannot easily be used to extract the fileid. Therefore XEDIT passes the BFS fileid as arg(2) to PROFILE XEDIT.
 Copyright IBM Corp. 1998 21
A simple solution might be:
BFS=(arg()>1) /* Is this is a BFS file ? */
if bfs then parse arg  options , fn  ft fm
else parse arg fn ft fm  options
When the PROFILE XEDIT wants to do some setup depending on the filetype, a few changes are required as well. An example analyzing a BFS fileid:
 COMMAND EXTRACT /FN/FT/FM/PNAME/
if pname.2<>  then do /* This is a BFS file */
Parse Value Reverse(pname.2) with ext  name  Path
Path = Reverse(Path)
name = Reverse(name)
type = Reverse(ext)
end
else type=ftype.1

BFSLIST – Listing the Contents of a BFS Directory
As mentioned earlier, Java programs are stored in the BFS. As FILELIST cannot be used to list BFS files, you feel lost, you cannot easily see what files and directories are available. There is the OPENVM LISTFILE command and the ls POSIX Shell command. But as illustrated below, they produce line mode output, hence dont compare with FILELIST but with LISTFILE. Note also that both OPENVM LISTFILE and the shell command ls -al return a GMT time as time of last change whereas we are used to seeing local times.

OPENVM LISTFILE
Below you can find the console output of a few OPENVM commands. Before using a BFS, a file system must be mounted. In a native CMS environment this is done by the OPENVM MOUNT command. Then we issue OPENVM SET DIR to define our working directory.
Readers with a Unix background are used to the above terminology. Readers with CMS experience may need some help: one could compare OPENVM MOUNT with CP LINK someuser somedev 191 M or with SET FILEPOOL mypool. Whereas OPENVM SET DIR can be compared accessing the ªA-diskº: ACCESS somedev A or
ACCESS someuser.somesubdir A.
Note: The BFS is a case sensitive file repository (all of Unix is case sensitive: ls is not the same as Ls). Therefore all parameters of the OPENVM command that refer to files are case sensitive too: /home/kris exists in BFS, but /home/KRIS doesnt.
POSIX Shell and Utilities
With the POSIX Shell and Utilities feature of VM, one gets the common Unix commands, such as ls, mkdir and mount. The POSIX Shell is started by entering POSIX on the command line.
Most CMS users have a PROFILE EXEC that is run to personalize their CMS environment. In the POSIX Shell a .profile file performs a similar function for the Unix environment: a filesystem is mounted and a working directory is defined. So for brevity we dont show mount or cd commands in the console that follows.

BFSLIST
Being spoiled with fullscreen tools such as FILELIST and DIRLIST, having to work with linemode only tools feels like returning to the stone age. In addition, when BFS, with Unix file structures, is new to you, you will feel even more lost. Only when you start getting an overview of the BFS directories and files will you begin to feel at home.
In a previous project a fullscreen tool, named BFSLIST was created to provide CMS users with a more user-friendly interface to the BFS. It is offered with redbook OpenEdition for VM/ESA Implementation and Administration, SG24-4747. That version of BFSLIST had some shortcomings and did no longer work perfectly in VM/ESA 2.3.0. So we greatly enhanced it.
The new version of BFSLIST is pictured below. The end-user interface is now more like FILELIST: you can enter commands against the listed BFS objects.
BFS File Naming – BFSLIST Terminology
BFSLIST uses the terms filename and filetype. They do have a slightly different meaning than in a traditional CMS environment. Lets take the third file shown by BFSLIST as an example:
F GetPerf.nrx rw-rw-rw- kris system 9K 1998/02/24 12:50:08
The full name of this file is /home/kris/GetPerf.nrx, which is called a pathname in the POSIX environment (in CMS you can issue HELP OPENVM PATHNAME to learn more about pathnames).
In this pathname we can distinguish a path: /home/kris/ and a name:
GuiPerf.nrx. CMS users may tend to say: ªGetPerf is the filename and nrx is the filetype.º This seems OK as there are two distinct parts in the name, just as in traditional CMS file names.
But remember that /home/kris/GuiMon.java.keep is a valid BFS file name too. As it has three parts in the name, the CMS filename and filetype terms are no longer appropriate.
On the other hand, a BFS holds different types of objects: files, directories, links, symbolic links and external links (issue HELP OPENVM MENU to learn more about links).
Therefore, in BFSLIST we use filetype to refer to the type of object. The filetype is the first word of each BFSLIST line. You can expect to see the following types:
stands for a file
stands for a directory
stands for a symbolic link or an external MOUNT
(lowercase l) stands for a link
is an external link (for example to a CMS file)
others issue HELP PIPE BFSSTATE to find a description for other types.
You can use BFSLIST s Q command to find more information about link objects.

Execution Parameters
BFSLIST accepts one parameter: the pathname to list. The default is your current working directory, as defined in the POSIX Shell or with the OPENVM SET DIR command.
To list the root directory, issue BFSLIST /.

Walking Through the Directory Tree
PF9 can be used to only see directories, and PF11 will open the directory pointed to with the cursor. Use PF3 to close a directory and PF5 to see all entries of the listed directory.
PF10, Parent, opens the parent directory of the directory being listed.

Sorting
The list of objects can be sorted, either by entering sort commands in the command line, or by using a predefined PF key. The following sort commands are defined: SNAME, SDATE, SSIZE, and STYPE.

Chapter 1. Introduction
Chapter 2. Overview of NetRexx and Java on VM/ESA
2.1 Java, NetRexx, OpenEdition, and the BFS
2.2 Overview of the SFS
2.3 Overview of the BFS
2.4 Some Common SFS and BFS Commands
2.5 The Java Environment Under VM
2.6 SFS and BFS Directory Structures
2.7 Installing Java and NetRexx without the Shell and Utilities
2.8 Adding a NetRexx Developer User ID
Chapter 3. Tools Used During the Project
3.1 XEDIT
3.2 BFSLIST – Listing the Contents of a BFS Directory
3.3 BFSTREE – Listing a BFS Directory Tree
3.4 NetRexx Compile
3.5 JC EXEC – Java Compile
3.6 NetRexx Run
3.7 Tools for the POSIX Shell Users
3.8 SETCENV – Setting C Environment Variables
Chapter 4. Comparing REXX to NetRexx
4.1 REXX¢s Position
4.2 NetRexx¢s Position
4.3 NetRexx Syntax Introduction
Chapter 5. AboutFrame, a Reusable Class
5.1 The AboutFrame Picture
5.2 What is AboutFrame?
5.3 AboutFrame: User Interface
5.4 AboutFrame: Program Interface
5.5 Classes and Methods
5.6 AboutFrame: the Class Definition
Chapter 6. Reading and Writing Files from NetRexx
6.1 Reading BFS Character Data Files
6.2 Reading from the console
6.3 Writing BFS Character Data Files
6.4 Working With Binary Files
Chapter 7. Code Pages – ASCII <> EBCDIC Issues
7.1 History, Experience
7.2 Background Information – Codepages
7.3 Internationalization
7.4 VM Java Codepage
7.5 IBM Network Station and Codepages
Chapter 8. TCP/IP Networking
8.1 Translating between EBCDIC and ASCII
8.2 Simple TCP/IP Client
8.3 Simple TCP/IP Server
Chapter 9. Java and CMS
9.1 Executing non-Java Programs
9.2 The cms.util Package
9.3 Running CMS Execs
9.4 Running CMS Pipelines with NetRexx
9.5 Installation Instructions
Chapter 10. The GUIMON Sample Program
10.1 GUIMON – Pictures
10.2 GUIMON – Installation Instructions
10.3 GUIMON – Functional Overview
10.4 GUIMON – the Client-Server Communication
10.5 GUIMON Record Format Requirements
Chapter 11. Running NetRexx and Java Applications on a Network Station
11.1 Network Computing – Extending VM/ESA Resources into the Network
11.2 VM/ESA as a Network Station Server
11.3 Support Delivery Mechanism
11.4 Hardware Requirements for VM/ESA
11.5 Software Requirements for VM/ESA
11.6 Major Steps to Install VM/ESA Network Station Code
11.7 Java Programs on the IBM Network Station
11.8 Setting up to Run Java and NetRexx Programs
11.9 Starting a Java or NetRexx Program on your IBM Network Station
11.10 How to Tailor the Local File System
11.11 Using NSM to Add a Java Application to the Menu Bar
11.12 Starting the GuiMon Application on the Network Station
Appendix

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *