File: runProgram-doc.m2

package info (click to toggle)
macaulay2 1.25.05%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 172,152 kB
  • sloc: cpp: 107,824; ansic: 16,193; javascript: 4,189; makefile: 3,899; lisp: 702; yacc: 604; sh: 476; xml: 177; perl: 114; lex: 65; python: 33
file content (156 lines) | stat: -rw-r--r-- 4,434 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
doc ///
  Key
    ProgramRun
  Headline
    result of running an external program
  Description
    Text
      A hash table returned by @TO runProgram@ with the following
      strings as keys:

      @UL {
	 {TT "\"command\"", ", the command that was used to run the program."},
	 {TT "\"output\"", ", the output of the program to ", TT "stdout", "."},
	 {TT "\"error\"", ", the output of the program to ", TT "stderr", "."},
	 {TT "\"return value\"", ", the return value of the program, ",
	     "possibly multiplied by 256 (see ", TO "run", ").  ",
	     "Note that this is what is displayed when printing a ",
	     TT "ProgramRun", " object."}}@

      In addition, if @TO runProgram@ is called with the @TT "KeepFiles"@
      option set to @TO true@, then the following keys will be present:

      @UL {
	 {TT "\"output file\"", ", the path to a file containing the output ",
	     "of the program to ", TT "stdout", "."},
	 {TT "\"error file\"", ", the path to a file containing the output ",
	     "of the program to ", TT "stderr", "."}}@
  SeeAlso
    runProgram
    (symbol <<, Program, Thing)
    Program
  Subnodes
    (status, ProgramRun)
///

doc ///
  Key
    runProgram
    (runProgram, Program, String)
    (runProgram, Program, String, String)
    (runProgram, String, String)
    [runProgram, KeepFiles]
    [runProgram, RaiseError]
    [runProgram, RunDirectory]
    [runProgram, Verbose]
  Headline
    run an external program
  Usage
    runProgram(program, args)
    runProgram(program, exe, args)
  Inputs
    program:Program
      the program to run, generated by @TO findProgram@.
    exe:String
      the specific executable file to run. This is only necessary if
      the program consists of multiple such files.  If not given, then
      @TT "program#\"name\""@ is used.
    args:String
      the command line arguments passed to the program.
    KeepFiles => Boolean
      whether to keep the temporary files containing the program's output.
    RaiseError => Boolean
      whether to raise an error if the program returns a nonzero value.
    RunDirectory => String
      the directory from which to run the program.  If it does not
      exist, then it will be created.  If @TO null@, then the program
      will be run from the current working directory (see
      @TO currentDirectory@).
    Verbose => Boolean
      whether to print the command line input and the program's output.
  Description
    Text
      This method runs an external program which has already been
      loaded using @TO findProgram@.  The results of this run are
      available in a @TO ProgramRun@ object.
    Example
      gfan = findProgram("gfan", "gfan --help")
      runProgram(gfan, "_version")
      oo#"output"
      runProgram(gfan, "_foo", RaiseError => false)
      oo#"error"
    Text
      The value corresponding to the @TT "\"output\""@ key may also be
      obtained using @TO toString@.
    Example
      toString runProgram(gfan, "_version")
    Text
      It is also possible to skip @TO findProgram@ and just provide
      two strings: the name of the program and the command line
      arguments.
    Example
      runProgram("normaliz", "--version")
      peek oo
    Text
      Internally, this routine uses @TO run@.
      Another way to interact with programs is to pass a string beginning
      with "!" to @TO get@, @TO openIn@, @TO openOut@, or @TO openInOut@.
  SeeAlso
    Program
    findProgram
    (status, ProgramRun)
    run
    get
  Subnodes
    ProgramRun
///

doc ///
  Key
    (status, ProgramRun)
  Headline
    get the return status of a program run
  Usage
    status pr
  Inputs
    pr:ProgramRun
  Outputs
    :ZZ
  Description
    Text
      Get the return status of a program run.  Usually, 0 means that it was
      successful.
    Example
      normaliz = findProgram "normaliz"
      status runProgram(normaliz, "--version")
  SeeAlso
    findProgram
    runProgram
///

doc ///
  Key
    (symbol <<, Program, Thing)
  Headline
    run program with input redirection
  Usage
    prog << x
  Inputs
    prog:Program
    x:Thing
  Outputs
    :ProgramRun
  Description
    Text
      Write @TT "x"@ to a temporary file and run @TT "prog"@ with this
      file as input using input redirection (the @TT "<"@ operator in
      a POSIX shell).
    Example
      M2 = findProgram "M2"
      M2 << "2 + 2"
      toString oo
  SeeAlso
    findProgram
    runProgram
    get
///