man g.ask () - Prompts the user for the names of GRASS data base files.

NAME

g.ask - Prompts the user for the names of GRASS data base files.

SYNOPSIS

g.ask

g.ask help

g.ask type=string [prompt="string"] element=string [desc="string"] unixfile=string

Parameters:

"type=string
The type of query Options: old,new,any,mapset
prompt= The prompt to be displayed to the user
"element=string
The database element to be queried
desc= A short description of the database element
"unixfile=string
The name of a unix file to store the user's response

DESCRIPTION

g.ask is designed for shell scripts that need to prompt the user for the name of a data base file in the user's current GRASS location. After g.ask is invoked with needed parameters, it will query the user for a file name of the specified type and element. After the user responds to this query, the program will write four lines to the UNIX output file specified by unixfile.

OPTIONS

Parameters:

"type=name
The type of query. Options for name are old, new, any, and mapset; their functions are given below. New", "any", and "mapset" only look in the user's current mapset.
"old
For existing data files anywhere in the user's mapset search path.
"new
Used to create a new file in the current mapset, which must not already exist there (if a file with this name exists there, it will not be overwritten).
"any
Creates a file in the current mapset, which may or may not already exist there. If a file with this name exists in the current mapset, it will be overwritten; if not, a new file with this name will be created.
"mapset
For files that must exist in the current mapset The shell write wants the name of a file which exists in the user's current mapset. This type would used instead of "old" if the file is to be modified.

prompt=
The prompt to be displayed to the user. If more than one word, the prompt should be enclosed within double quotes ("").
"element=name
The name of the GRASS data base element (i.e., directory under a GRASS mapset) whose files are to be queried.
desc=
A short description of the data base element which is meaningful to the user. If description contains more than one word, it should be enclosed within double quotes ("").
"unixfile=name
The name of a UNIX file to store the user's response. See next section for what is written to this file and how it can be used by shell scripts.

OUTPUT

Upon receiving the user's response to its request for a file name, g.ask writes four lines to the specified unixfile; this output file is placed in the user's current working directory, unless otherwise specified, and contains the following lines: name='some_name'

mapset='some_mapset'

fullname='some_fullname'

file='some_fullpath'

The output is /bin/sh commands to set the variable name to the file name specified by the user (of the element and type requested by g.ask), mapset to the GRASS mapset in which this file resides (or will be created), fullname is the name with the mapset embedded in it, and file to the full UNIX path name identifying this file. These variables may be set in the /bin/sh as follows: . unixfile

The . is a shell command which means read the unixfile and execute the commands found there. It is NOT part of the unixfile name and MUST be followed by a space.

NOTES

The user may choose to simply hit the return key and not enter a file name. If this happens the variables will be set as follows: name=

mapset=

fullname=

file=

The following is a way to test for this case:

if [ ! "$file" ]

then

exit

fi

SEE ALSO

d.ask, g.filename, g.findfile, g.gisenv, g.parser

AUTHOR

Michael Shapiro, U.S.Army Construction Engineering Research Laboratory

Last changed: $Date: 2003/05/07 08:19:28 $

Help Index