RESOURCE NOTES

NO. 11 DATE 1/6/00

Creating and

Saving Query Files

in the Wild Horse

and Burro (HB)

System

by Dick Stark, User

Representative, National

Applied Resource Sciences

Center (RS-140)

Background

The Bureau of Land Management’s

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 user’s own directory, so they

may be called and reused whenever

necessary. Following is a method to

do this.

Discussion

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 rstark’s

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:

hm;e65=al;ar;fl;ga;ky;la;ms;nc;sc;tn;va

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 rstark’s 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

adopter’s last name, first name,

home phone, and business phone

where the adopter’s 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

Range

Wild Horse andBurro Program
enter key at the end of each line to

move to the next line:

ix;arizona

p;(e58;e59;e67;e68) for e65=az

tx

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:

ix;pvcinventory

hm;e40=nv53

p;(e27;e25;e29;e53) for r

tx

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 you’re in (example: ls).

ex; allows use of Unix commands from an Aspen/2

prompt (example: 

ex;cat arizona).

rm removes a file from the 

directory you’re in (example:

rm arizona removes the file

“arizona” from the directory).

Conclusion

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.

Contact

Dick Stark

BLM, RS-140

P.O. Box 25047

Denver, CO 80225-0047

(303) 236-0157

email:rstark@blm.gov

Range

Range

Range

Resource Notes are intended to be early

announcements of technical and informational topics for

Bureau of Land Management personnel and some of their customers.

Information in this Resource Note is based on the opinion and

experience of the author and has not been peer-reviewed. Conclusions

and opinions expressed herein do not

necessarily represent those of BLM. Use of trade names does not

imply U.S. Government endorsement of commercial products.

If you have received a copy of or found out about Resource

Notes in an indirect way and would like to be included in future

mailings, please send the following:

NAME, TITLE, MAILING ADDRESS and a list of the two or three

subject areas that you are most interested in or that most directly

relate to your job. Send this information to Phil Dittberner, BLM,

RS-140, P.O. Box 25047, Denver, CO. 80225-0047 or

phil_dittberner@blm.gov or FAX 303-236-3508.

If you would like to prepare a Resource Note for

distribution, or you have an idea and author in mind for a good

Resource Note, please contact Phil Dittberner at

303-236-1833, FAX 303-236-3508 or phil_dittberner@blm.gov with

the topic and the name of writer, including an address, phone number, and e-mail address.

Thank you for your interest in Resource NoteS.