3294
|
1 @c Copyright (C) 1996, 1997 John W. Eaton |
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
3452
|
5 @node System Utilities, Tips, Quaternions, Top |
3294
|
6 @chapter System Utilities |
|
7 |
|
8 This chapter describes the functions that are available to allow you to |
|
9 get information about what is happening outside of Octave, while it is |
|
10 still running, and use this information in your program. For example, |
|
11 you can get information about environment variables, the current time, |
|
12 and even start other programs from the Octave prompt. |
|
13 |
|
14 @menu |
|
15 * Timing Utilities:: |
|
16 * Filesystem Utilities:: |
|
17 * Controlling Subprocesses:: |
|
18 * Process ID Information:: |
|
19 * Environment Variables:: |
|
20 * Current Working Directory:: |
|
21 * Password Database Functions:: |
|
22 * Group Database Functions:: |
|
23 * System Information:: |
|
24 @end menu |
|
25 |
|
26 @node Timing Utilities, Filesystem Utilities, System Utilities, System Utilities |
|
27 @section Timing Utilities |
|
28 |
|
29 Octave's core set of functions for manipulating time values are |
|
30 patterned after the corresponding functions from the standard C library. |
|
31 Several of these functions use a data structure for time that includes |
|
32 the following elements: |
|
33 |
|
34 @table @code |
|
35 @item usec |
|
36 Microseconds after the second (0-999999). |
|
37 |
|
38 @item sec |
|
39 Seconds after the minute (0-61). This number can be 61 to account |
|
40 for leap seconds. |
|
41 |
|
42 @item min |
|
43 Minutes after the hour (0-59). |
|
44 |
|
45 @item hour |
|
46 Hours since midnight (0-23). |
|
47 |
|
48 @item mday |
|
49 Day of the month (1-31). |
|
50 |
|
51 @item mon |
|
52 Months since January (0-11). |
|
53 |
|
54 @item year |
|
55 Years since 1900. |
|
56 |
|
57 @item wday |
|
58 Days since Sunday (0-6). |
|
59 |
|
60 @item yday |
|
61 Days since January 1 (0-365). |
|
62 |
|
63 @item isdst |
|
64 Daylight Savings Time flag. |
|
65 |
|
66 @item zone |
|
67 Time zone. |
|
68 @end table |
|
69 |
|
70 @noindent |
|
71 In the descriptions of the following functions, this structure is |
|
72 referred to as a @var{tm_struct}. |
|
73 |
3301
|
74 @DOCSTRING(time) |
3294
|
75 |
|
76 @DOCSTRING(ctime) |
|
77 |
3301
|
78 @DOCSTRING(gmtime) |
3294
|
79 |
3301
|
80 @DOCSTRING(localtime) |
3294
|
81 |
3301
|
82 @DOCSTRING(mktime) |
3294
|
83 |
3301
|
84 @DOCSTRING(asctime) |
3294
|
85 |
|
86 @DOCSTRING(strftime) |
|
87 |
|
88 Most of the remaining functions described in this section are not |
|
89 patterned after the standard C library. Some are available for |
|
90 compatiblity with @sc{Matlab} and others are provided because they are |
|
91 useful. |
|
92 |
3301
|
93 @DOCSTRING(clock) |
3294
|
94 |
3301
|
95 @DOCSTRING(date) |
3294
|
96 |
3301
|
97 @DOCSTRING(etime) |
3294
|
98 |
3301
|
99 @DOCSTRING(cputime) |
3294
|
100 |
3301
|
101 @DOCSTRING(is_leap_year) |
3294
|
102 |
3301
|
103 @DOCSTRING(tic) |
3294
|
104 |
3301
|
105 @DOCSTRING(pause) |
3294
|
106 |
3301
|
107 @DOCSTRING(sleep) |
3294
|
108 |
3301
|
109 @DOCSTRING(usleep) |
3294
|
110 |
|
111 @node Filesystem Utilities, Controlling Subprocesses, Timing Utilities, System Utilities |
|
112 @section Filesystem Utilities |
|
113 |
|
114 Octave includes the following functions for renaming and deleting files, |
|
115 creating, deleting, and reading directories, and for getting information |
|
116 about the status of files. |
|
117 |
3301
|
118 @DOCSTRING(rename) |
3294
|
119 |
3301
|
120 @DOCSTRING(unlink) |
3294
|
121 |
3301
|
122 @DOCSTRING(readdir) |
3294
|
123 |
3301
|
124 @DOCSTRING(mkdir) |
3294
|
125 |
3301
|
126 @DOCSTRING(rmdir) |
3294
|
127 |
3301
|
128 @DOCSTRING(mkfifo) |
3294
|
129 |
3301
|
130 @DOCSTRING(umask) |
3294
|
131 |
3301
|
132 @DOCSTRING(stat) |
3294
|
133 |
3301
|
134 @DOCSTRING(glob) |
3294
|
135 |
3428
|
136 @DOCSTRING(fnmatch) |
|
137 |
3301
|
138 @DOCSTRING(file_in_path) |
3294
|
139 |
3301
|
140 @DOCSTRING(tilde_expand) |
3294
|
141 |
|
142 @node Controlling Subprocesses, Process ID Information, Filesystem Utilities, System Utilities |
|
143 @section Controlling Subprocesses |
|
144 |
|
145 Octave includes some high-level commands like @code{system} and |
|
146 @code{popen} for starting subprocesses. If you want to run another |
|
147 program to perform some task and then look at its output, you will |
|
148 probably want to use these functions. |
|
149 |
|
150 Octave also provides several very low-level Unix-like functions which |
|
151 can also be used for starting subprocesses, but you should probably only |
|
152 use them if you can't find any way to do what you need with the |
|
153 higher-level functions. |
|
154 |
3301
|
155 @DOCSTRING(system) |
3294
|
156 |
3301
|
157 @DOCSTRING(popen) |
3294
|
158 |
3301
|
159 @DOCSTRING(pclose) |
3294
|
160 |
3301
|
161 @DOCSTRING(popen2) |
3294
|
162 |
3301
|
163 @DOCSTRING(EXEC_PATH) |
3294
|
164 |
|
165 In most cases, the following functions simply decode their arguments and |
|
166 make the corresponding Unix system calls. For a complete example of how |
|
167 they can be used, look at the definition of the function @code{popen2}. |
|
168 |
3301
|
169 @DOCSTRING(fork) |
3294
|
170 |
3301
|
171 @DOCSTRING(exec) |
3294
|
172 |
3301
|
173 @DOCSTRING(pipe) |
3294
|
174 |
3301
|
175 @DOCSTRING(dup2) |
3294
|
176 |
3301
|
177 @DOCSTRING(waitpid) |
3294
|
178 |
3301
|
179 @DOCSTRING(fcntl) |
3294
|
180 |
|
181 @node Process ID Information, Environment Variables, Controlling Subprocesses, System Utilities |
|
182 @section Process, Group, and User IDs |
|
183 |
3301
|
184 @DOCSTRING(getpgrp) |
3294
|
185 |
3301
|
186 @DOCSTRING(getpid) |
3294
|
187 |
3301
|
188 @DOCSTRING(getppid) |
3294
|
189 |
3301
|
190 @DOCSTRING(geteuid) |
3294
|
191 |
3301
|
192 @DOCSTRING(getuid) |
3294
|
193 |
3301
|
194 @DOCSTRING(getegid) |
3294
|
195 |
3301
|
196 @DOCSTRING(getgid) |
3294
|
197 |
|
198 @node Environment Variables, Current Working Directory, Process ID Information, System Utilities |
|
199 @section Environment Variables |
|
200 |
3301
|
201 @DOCSTRING(getenv) |
3294
|
202 |
3301
|
203 @DOCSTRING(putenv) |
3294
|
204 |
|
205 @node Current Working Directory, Password Database Functions, Environment Variables, System Utilities |
|
206 @section Current Working Directory |
|
207 |
3301
|
208 @DOCSTRING(cd) |
3294
|
209 |
3301
|
210 @DOCSTRING(ls) |
3294
|
211 |
3301
|
212 @DOCSTRING(pwd) |
3294
|
213 |
|
214 @node Password Database Functions, Group Database Functions, Current Working Directory, System Utilities |
|
215 @section Password Database Functions |
|
216 |
|
217 Octave's password database functions return information in a structure |
|
218 with the following fields. |
|
219 |
|
220 @table @code |
|
221 @item name |
|
222 The user name. |
|
223 |
|
224 @item passwd |
|
225 The encrypted password, if available. |
|
226 |
|
227 @item uid |
|
228 The numeric user id. |
|
229 |
|
230 @item gid |
|
231 The numeric group id. |
|
232 |
|
233 @item gecos |
|
234 The GECOS field. |
|
235 |
|
236 @item dir |
|
237 The home directory. |
|
238 |
|
239 @item shell |
|
240 The initial shell. |
|
241 @end table |
|
242 |
|
243 In the descriptions of the following functions, this data structure is |
|
244 referred to as a @var{pw_struct}. |
|
245 |
3301
|
246 @DOCSTRING(getpwent) |
3294
|
247 |
3301
|
248 @DOCSTRING(getpwuid) |
3294
|
249 |
3301
|
250 @DOCSTRING(getpwnam) |
3294
|
251 |
3301
|
252 @DOCSTRING(setpwent) |
3294
|
253 |
3301
|
254 @DOCSTRING(endpwent) |
3294
|
255 |
|
256 @node Group Database Functions, System Information, Password Database Functions, System Utilities |
|
257 @section Group Database Functions |
|
258 |
|
259 Octave's group database functions return information in a structure |
|
260 with the following fields. |
|
261 |
|
262 @table @code |
|
263 @item name |
|
264 The user name. |
|
265 |
|
266 @item passwd |
|
267 The encrypted password, if available. |
|
268 |
|
269 @item gid |
|
270 The numeric group id. |
|
271 |
|
272 @item mem |
|
273 The members of the group. |
|
274 @end table |
|
275 |
|
276 In the descriptions of the following functions, this data structure is |
|
277 referred to as a @var{grp_struct}. |
|
278 |
3301
|
279 @DOCSTRING(getgrent) |
3294
|
280 |
3301
|
281 @DOCSTRING(getgrgid) |
|
282 |
|
283 @DOCSTRING(getgrnam) |
3294
|
284 |
3301
|
285 @DOCSTRING(setgrent) |
3294
|
286 |
3301
|
287 @DOCSTRING(endgrent) |
3294
|
288 |
|
289 @node System Information, , Group Database Functions, System Utilities |
|
290 @section System Information |
|
291 |
3301
|
292 @DOCSTRING(computer) |
3294
|
293 |
3301
|
294 @DOCSTRING(isieee) |
3294
|
295 |
3301
|
296 @DOCSTRING(OCTAVE_VERSION) |
3294
|
297 |
3301
|
298 @DOCSTRING(octave_config_info) |
3294
|
299 |
3301
|
300 @DOCSTRING(getrusage) |