Skip to content

Meta Commands and File Redirection

Ross Scroggs edited this page Aug 2, 2019 · 20 revisions

Meta Commands

For information about the GAMADV-X configuration file gam.cfg, see: GAM Configuration

<Select> <SelectFilter> <Config> <Redirect> must come before all other arguments and in this order, ... indicates that additional GAM arguments may appear.

gam [<Select>] [<SelectFilter>] [<Config>] [<Redirect>] ...

[<Select>] [<SelectFilter>] [<Config>] [<Redirect>] will not be shown in the following command descriptions but can be used with any Gam command.

Select a section from gam.cfg and process a GAM command using values from that section.

<Select> ::=
        select <Section> [save] [verify]
  • save
    • Set section = <Section> in the [DEFAULT] section and write configuration data to gam.cfg
  • verify
    • Print the variable values for the selected section
    • Values are determined in this order: Selected section, DEFAULT section, Program default

Select a filter section from gam.cfg and process a GAM command using values from that section

The only <VariableName>s recognized in this <Section> are: csv_output_header_filter and csv_output_row_filter

<SelectFilter> ::=
        selectfilter <Section>

Set variables in gam.cfg.

<Config> ::=
        config (<VariableName> [=] <Value)* [save] [verify]
  • <VariableName> [=] <Value>
    • Set <VariableName> = <Value> in the current section
    • All <VariableNames> except section are allowed.
    • The = is optional but must be surrounded by spaces if included.
  • save
    • Write configuration data to gam.cfg
  • verify
    • Print the variable values for the current section
    • Values are determined in this order: Current section, DEFAULT section, Program default

File Redirection

You can redirect CSV file output and stdout/stderr output to files. By using redirect, you have more control over the output from gam. The multiprocess subargument allows the multiple processes started by gam csv to write intelligently to a redirected CSV/stdout/stderr file. You can redirect stdout and stderr to null and stderr can be redirected to stdout.

<Redirect> ::=
        redirect csv <FileName> [multiprocess] [append] [noheader] [charset <Charset>] [columndelimiter <Character>] [quotechar <Character>] |
        redirect stdout <FileName> [multiprocess] [append] |
        redirect stdout null [multiprocess] |
        redirect stderr <FileName> [multiprocess] [append] |
        redirect stderr null [multiprocess] |
        redirect stderr stdout [multiprocess]

For redirect csv, the optional arguments must appear in the order shown.

If <FileName> specifies a relative path, the file will be put in the directory specified by drive_dir in gam.cfg. Specify ./<FileName> to put the file in your current working directory.

If the pattern {{Section}} appears in <FileName>, it will be replaced with the name of the current section of gam.cfg.

Examples - Redirect stdout

The output from each of the gam info user ~primaryEmail commands will be combined into the single file Users.txt. The value of show_multiprocess_info from gam.cfg controls whether information identifying the processes is also shown.

$ gam config show_multiprocess_info false redirect stdout ./Users.txt multiprocess csv Users.csv gam info user ~primaryEmail
$ more Users.txt
User: [email protected] (1/1)
  Settings:
    First Name: Test
    Last Name: User1
    Full Name: Test User1
...
User: [email protected]@ (1/1)
  Settings:
    First Name: Test
    Last Name: User2
    Full Name: Test User2
...

$ gam config show_multiprocess_info true redirect stdout ./Users.txt multiprocess csv Users.csv gam info user ~primaryEmail
$ more Users.txt
stdout:      0, Start: 2017-01-26T11:35:00.897773-08:00, RC:   0, Cmd: /Users/admin/gam config show_multiprocess_info true redirect stdout ./Users.txt multiprocess csv Users.csv gam info user ~primaryEmail
stdout:      1, Start: 2017-01-26T11:35:00.902709-08:00, RC:   0, Cmd: gam info user [email protected]
User: [email protected] (1/1)
  Settings:
    First Name: Test
    Last Name: User1
    Full Name: Test User1
...
stdout:      1,   End: 2017-01-26T11:35:02.656837-08:00, RC:   0, Cmd: gam info user [email protected]
stdout:      2, Start: 2017-01-26T11:35:00.910729-08:00, RC:   0, Cmd: gam info user [email protected]
User: [email protected]@ (1/1)
  Settings:
    First Name: Test
    Last Name: User2
    Full Name: Test User2
...
stdout:      2,   End: 2017-01-26T11:35:02.849646-08:00, RC:   0, Cmd: gam info user [email protected]
stdout:      0,   End: 2017-01-26T11:35:02.907141-08:00, RC:   0, Cmd: /Users/admin/gam config show_multiprocess_info true redirect stdout ./Users.txt multiprocess csv Users.csv gam info user ~primaryEmail

Example - redirect CSV

Suppose that you have a CSV file CourseList.csv with a column labeled CourseId that contains course Ids. You want a single CSV file with participant information for these courses.

gam redirect csv ./CourseInfo.csv multiprocess csv CourseList.csv gam print course-participants course ~CourseId

redirect csv ./CourseInfo.csv multiprocess causes gam to collect output from all of the processes started by csv CourseList.csv gam print course-participants course ~CourseId and produces a single CSV file CourseInfo.csv.

Update History

Installation

Configuration

Notes and Information

Definitions

Command Processing

Collections

Client Access

Special Service Account Access

Service Account Access

Clone this wiki locally