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 |
4167
|
5 @node System Utilities |
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 |
4167
|
26 @node Timing Utilities |
3294
|
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 |
4169
|
88 @DOCSTRING(strptime) |
|
89 |
3294
|
90 Most of the remaining functions described in this section are not |
|
91 patterned after the standard C library. Some are available for |
|
92 compatiblity with @sc{Matlab} and others are provided because they are |
|
93 useful. |
|
94 |
3301
|
95 @DOCSTRING(clock) |
3294
|
96 |
3301
|
97 @DOCSTRING(date) |
3294
|
98 |
3301
|
99 @DOCSTRING(etime) |
3294
|
100 |
3301
|
101 @DOCSTRING(cputime) |
3294
|
102 |
3301
|
103 @DOCSTRING(is_leap_year) |
3294
|
104 |
3301
|
105 @DOCSTRING(tic) |
3294
|
106 |
3301
|
107 @DOCSTRING(pause) |
3294
|
108 |
3301
|
109 @DOCSTRING(sleep) |
3294
|
110 |
3301
|
111 @DOCSTRING(usleep) |
3294
|
112 |
4167
|
113 @node Filesystem Utilities |
3294
|
114 @section Filesystem Utilities |
|
115 |
|
116 Octave includes the following functions for renaming and deleting files, |
|
117 creating, deleting, and reading directories, and for getting information |
|
118 about the status of files. |
|
119 |
3301
|
120 @DOCSTRING(rename) |
3294
|
121 |
3710
|
122 @DOCSTRING(link) |
|
123 |
|
124 @DOCSTRING(symlink) |
|
125 |
4169
|
126 @DOCSTRING(readlink) |
|
127 |
3301
|
128 @DOCSTRING(unlink) |
3294
|
129 |
3301
|
130 @DOCSTRING(readdir) |
3294
|
131 |
3301
|
132 @DOCSTRING(mkdir) |
3294
|
133 |
3301
|
134 @DOCSTRING(rmdir) |
3294
|
135 |
3301
|
136 @DOCSTRING(mkfifo) |
3294
|
137 |
3301
|
138 @DOCSTRING(umask) |
3294
|
139 |
3301
|
140 @DOCSTRING(stat) |
3294
|
141 |
3301
|
142 @DOCSTRING(glob) |
3294
|
143 |
3428
|
144 @DOCSTRING(fnmatch) |
|
145 |
3301
|
146 @DOCSTRING(file_in_path) |
3294
|
147 |
3301
|
148 @DOCSTRING(tilde_expand) |
3294
|
149 |
4167
|
150 @node Controlling Subprocesses |
3294
|
151 @section Controlling Subprocesses |
|
152 |
|
153 Octave includes some high-level commands like @code{system} and |
|
154 @code{popen} for starting subprocesses. If you want to run another |
|
155 program to perform some task and then look at its output, you will |
|
156 probably want to use these functions. |
|
157 |
|
158 Octave also provides several very low-level Unix-like functions which |
|
159 can also be used for starting subprocesses, but you should probably only |
|
160 use them if you can't find any way to do what you need with the |
|
161 higher-level functions. |
|
162 |
3301
|
163 @DOCSTRING(system) |
3294
|
164 |
3301
|
165 @DOCSTRING(popen) |
3294
|
166 |
3301
|
167 @DOCSTRING(pclose) |
3294
|
168 |
3301
|
169 @DOCSTRING(popen2) |
3294
|
170 |
3301
|
171 @DOCSTRING(EXEC_PATH) |
3294
|
172 |
|
173 In most cases, the following functions simply decode their arguments and |
|
174 make the corresponding Unix system calls. For a complete example of how |
|
175 they can be used, look at the definition of the function @code{popen2}. |
|
176 |
3301
|
177 @DOCSTRING(fork) |
3294
|
178 |
3301
|
179 @DOCSTRING(exec) |
3294
|
180 |
3301
|
181 @DOCSTRING(pipe) |
3294
|
182 |
3301
|
183 @DOCSTRING(dup2) |
3294
|
184 |
3301
|
185 @DOCSTRING(waitpid) |
3294
|
186 |
3301
|
187 @DOCSTRING(fcntl) |
3294
|
188 |
4167
|
189 @node Process ID Information |
3294
|
190 @section Process, Group, and User IDs |
|
191 |
3301
|
192 @DOCSTRING(getpgrp) |
3294
|
193 |
3301
|
194 @DOCSTRING(getpid) |
3294
|
195 |
3301
|
196 @DOCSTRING(getppid) |
3294
|
197 |
3301
|
198 @DOCSTRING(geteuid) |
3294
|
199 |
3301
|
200 @DOCSTRING(getuid) |
3294
|
201 |
3301
|
202 @DOCSTRING(getegid) |
3294
|
203 |
3301
|
204 @DOCSTRING(getgid) |
3294
|
205 |
4167
|
206 @node Environment Variables |
3294
|
207 @section Environment Variables |
|
208 |
3301
|
209 @DOCSTRING(getenv) |
3294
|
210 |
3301
|
211 @DOCSTRING(putenv) |
3294
|
212 |
4167
|
213 @node Current Working Directory |
3294
|
214 @section Current Working Directory |
|
215 |
3301
|
216 @DOCSTRING(cd) |
3294
|
217 |
3301
|
218 @DOCSTRING(ls) |
3294
|
219 |
3301
|
220 @DOCSTRING(pwd) |
3294
|
221 |
4167
|
222 @node Password Database Functions |
3294
|
223 @section Password Database Functions |
|
224 |
|
225 Octave's password database functions return information in a structure |
|
226 with the following fields. |
|
227 |
|
228 @table @code |
|
229 @item name |
|
230 The user name. |
|
231 |
|
232 @item passwd |
|
233 The encrypted password, if available. |
|
234 |
|
235 @item uid |
|
236 The numeric user id. |
|
237 |
|
238 @item gid |
|
239 The numeric group id. |
|
240 |
|
241 @item gecos |
|
242 The GECOS field. |
|
243 |
|
244 @item dir |
|
245 The home directory. |
|
246 |
|
247 @item shell |
|
248 The initial shell. |
|
249 @end table |
|
250 |
|
251 In the descriptions of the following functions, this data structure is |
|
252 referred to as a @var{pw_struct}. |
|
253 |
3301
|
254 @DOCSTRING(getpwent) |
3294
|
255 |
3301
|
256 @DOCSTRING(getpwuid) |
3294
|
257 |
3301
|
258 @DOCSTRING(getpwnam) |
3294
|
259 |
3301
|
260 @DOCSTRING(setpwent) |
3294
|
261 |
3301
|
262 @DOCSTRING(endpwent) |
3294
|
263 |
4167
|
264 @node Group Database Functions |
3294
|
265 @section Group Database Functions |
|
266 |
|
267 Octave's group database functions return information in a structure |
|
268 with the following fields. |
|
269 |
|
270 @table @code |
|
271 @item name |
|
272 The user name. |
|
273 |
|
274 @item passwd |
|
275 The encrypted password, if available. |
|
276 |
|
277 @item gid |
|
278 The numeric group id. |
|
279 |
|
280 @item mem |
|
281 The members of the group. |
|
282 @end table |
|
283 |
|
284 In the descriptions of the following functions, this data structure is |
|
285 referred to as a @var{grp_struct}. |
|
286 |
3301
|
287 @DOCSTRING(getgrent) |
3294
|
288 |
3301
|
289 @DOCSTRING(getgrgid) |
|
290 |
|
291 @DOCSTRING(getgrnam) |
3294
|
292 |
3301
|
293 @DOCSTRING(setgrent) |
3294
|
294 |
3301
|
295 @DOCSTRING(endgrent) |
3294
|
296 |
4167
|
297 @node System Information |
3294
|
298 @section System Information |
|
299 |
3301
|
300 @DOCSTRING(computer) |
3294
|
301 |
3301
|
302 @DOCSTRING(isieee) |
3294
|
303 |
3301
|
304 @DOCSTRING(OCTAVE_VERSION) |
3294
|
305 |
3301
|
306 @DOCSTRING(octave_config_info) |
3294
|
307 |
3301
|
308 @DOCSTRING(getrusage) |