NO. 11 DATE 1/6/00
by Dick Stark, User Representative, National Applied Resource Sciences Center (RS-140)
The Bureau of Land Managements HB system has been hosted on a Unix platform since January 1998. The query software is Aspen/2 Data Manager, a command line tool that allows retrieval of information from a flat file created periodically from an Informix relational database.
Resource program specialists often need to customize queries to address specific data needs and desired output formats. It is handy to be able to create and store these queries as files in the users own directory, so they may be called and reused whenever necessary. Following is a method to do this.
At the prompt indicating that
you are on the production MUP
in Denver (SC0123), call the
vi editor and enter the name of a file in which you want to save the commands. For demonstration purposes, we will use jackson as the filename to store a command in rstarks directory that will query about adopters who reside in the states administered by the Jackson field office:
sc0123:/u/rstark $ vi jackson
The screen will display with a tilde symbol (~) at the left edge of each line, except for the bottom line, which displays: jackson [New file].
Type in the letter i to enter the input mode; the machine displays the words INPUT MODE on the bottom line and sets the cursor on the first line: (see illustration below).
You can now type in commands that can be called from the Aspen/2 command line. For this example, we will enter commands that will produce an Aspen result consisting of all records in the disposal database where the adopter resides within the Jackson District administrative area:
To save the file, first press the Escape key (Esc) to exit the input mode, then enter <shift>ZZ to save the file. The machine responds with the message :
jackson [New file] 1 line, 40 characters
There is now a file in rstarks directory on the production MUP (sc0123) that contains this query.
It can be called from the Aspen/2 prompt by using the rx (read
auxiliary input) command:
Enter Next Command: rx;jackson
The machine responds with:
Query Response: 34405 out of 202343
WH&B Disposal Records, or 17.00%
a result that can be used as a starting point for further sort and print commands.
You can also save a series of commands that will be executed successively when called from Aspen, including initiating an auxiliary file (ix), saving selected records in it, and then terminating the file (tx). The following example would create a file called arizona containing adopters last name, first name, home phone, and business phone where the adopters state of residence is Arizona. Enter the visual editor as described above, move to input mode, and then type in the commands as follows, using the enter key at the end of each line to move to the next line:
p;(e58;e59;e67;e68) for e65=az
exit the editor by pressing ESC and save the file by typing in <shift>ZZ.
There will now be a file in your directory called arizona that can be called from Aspen/2 using the rx command:
Enter Next Command: rx;arizona
Another example could be used periodically in producing a facility inventory. The following commands would produce a file called pvcinventory listing animals in the Palomino Valley facility (NV53), sorted by necktag number and showing necktag number, freezemark, signalment key, and preparation date:
p;(e27;e25;e29;e53) for r
Be careful not to choose the same name for the output file as you use for the auxiliary file and to avoid spaces in filenames. Files with such names can be saved, but are not recognized by Unix.
There are a host of additional Unix commands useful in editing files. Your system administrator can refer you to the appropriate manuals. The following commands are handy to look at and manipulate files once they have been created. They can be entered at the Unix $ prompt or from Aspen/2, by prefixing them with the execute (ex;) command:
cat displays the contents of a file (example: cat arizona
displays the file arizona).
ls lists all the files in the directory youre in (example: ls).
ex; allows use of Unix commands from an Aspen/2 prompt (example:
rm removes a file from the
directory youre in (example: rm arizona removes the file arizona from the directory).
Creating and storing queries in this way is an efficient way to combine the query power of Aspen/2 and the editing capability of Unix.
P.O. Box 25047
Denver, CO 80225-0047
Return to Resource Notes Index
Search | Browse | BLM Home | DOI Home | Feedback | Sitemap
Products & Services | NSTC Directory | Organization Chart | S & T Project Review Board | BLM Library | Resource Notes
Air Quality | Engineering | Ecosystem Modeling | GIS | Wildfire
P.O. Box 25047
Bldg. 50, Denver Federal Center
Denver, Colorado 80225-0047
FAX (303) 236-6450
Before continuing, please
read this disclaimer and
Point of contact for technical issues:
You are visitor since xx/xx/xxxx.