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:: |
6549
|
17 * File Archiving Utilities:: |
|
18 * Networking Utilities:: |
3294
|
19 * Controlling Subprocesses:: |
|
20 * Process ID Information:: |
|
21 * Environment Variables:: |
|
22 * Current Working Directory:: |
|
23 * Password Database Functions:: |
|
24 * Group Database Functions:: |
|
25 * System Information:: |
|
26 @end menu |
|
27 |
4167
|
28 @node Timing Utilities |
3294
|
29 @section Timing Utilities |
|
30 |
|
31 Octave's core set of functions for manipulating time values are |
|
32 patterned after the corresponding functions from the standard C library. |
|
33 Several of these functions use a data structure for time that includes |
|
34 the following elements: |
|
35 |
|
36 @table @code |
|
37 @item usec |
|
38 Microseconds after the second (0-999999). |
|
39 |
|
40 @item sec |
|
41 Seconds after the minute (0-61). This number can be 61 to account |
|
42 for leap seconds. |
|
43 |
|
44 @item min |
|
45 Minutes after the hour (0-59). |
|
46 |
|
47 @item hour |
|
48 Hours since midnight (0-23). |
|
49 |
|
50 @item mday |
|
51 Day of the month (1-31). |
|
52 |
|
53 @item mon |
|
54 Months since January (0-11). |
|
55 |
|
56 @item year |
|
57 Years since 1900. |
|
58 |
|
59 @item wday |
|
60 Days since Sunday (0-6). |
|
61 |
|
62 @item yday |
|
63 Days since January 1 (0-365). |
|
64 |
|
65 @item isdst |
|
66 Daylight Savings Time flag. |
|
67 |
|
68 @item zone |
|
69 Time zone. |
|
70 @end table |
|
71 |
|
72 @noindent |
|
73 In the descriptions of the following functions, this structure is |
|
74 referred to as a @var{tm_struct}. |
|
75 |
3301
|
76 @DOCSTRING(time) |
3294
|
77 |
6502
|
78 @DOCSTRING(now) |
|
79 |
3294
|
80 @DOCSTRING(ctime) |
|
81 |
3301
|
82 @DOCSTRING(gmtime) |
3294
|
83 |
3301
|
84 @DOCSTRING(localtime) |
3294
|
85 |
3301
|
86 @DOCSTRING(mktime) |
3294
|
87 |
3301
|
88 @DOCSTRING(asctime) |
3294
|
89 |
|
90 @DOCSTRING(strftime) |
|
91 |
4169
|
92 @DOCSTRING(strptime) |
|
93 |
3294
|
94 Most of the remaining functions described in this section are not |
|
95 patterned after the standard C library. Some are available for |
|
96 compatiblity with @sc{Matlab} and others are provided because they are |
|
97 useful. |
|
98 |
3301
|
99 @DOCSTRING(clock) |
3294
|
100 |
3301
|
101 @DOCSTRING(date) |
3294
|
102 |
3301
|
103 @DOCSTRING(etime) |
3294
|
104 |
3301
|
105 @DOCSTRING(cputime) |
3294
|
106 |
3301
|
107 @DOCSTRING(is_leap_year) |
3294
|
108 |
3301
|
109 @DOCSTRING(tic) |
3294
|
110 |
3301
|
111 @DOCSTRING(pause) |
3294
|
112 |
3301
|
113 @DOCSTRING(sleep) |
3294
|
114 |
3301
|
115 @DOCSTRING(usleep) |
3294
|
116 |
6502
|
117 @DOCSTRING( datenum) |
|
118 |
|
119 @DOCSTRING(datestr) |
|
120 |
|
121 @DOCSTRING(datevec) |
|
122 |
|
123 @DOCSTRING(calendar) |
|
124 |
|
125 @DOCSTRING(weekday) |
|
126 |
|
127 @DOCSTRING(eomday) |
|
128 |
4167
|
129 @node Filesystem Utilities |
3294
|
130 @section Filesystem Utilities |
|
131 |
|
132 Octave includes the following functions for renaming and deleting files, |
|
133 creating, deleting, and reading directories, and for getting information |
|
134 about the status of files. |
|
135 |
3301
|
136 @DOCSTRING(rename) |
3294
|
137 |
3710
|
138 @DOCSTRING(link) |
|
139 |
|
140 @DOCSTRING(symlink) |
|
141 |
4169
|
142 @DOCSTRING(readlink) |
|
143 |
3301
|
144 @DOCSTRING(unlink) |
3294
|
145 |
3301
|
146 @DOCSTRING(readdir) |
3294
|
147 |
3301
|
148 @DOCSTRING(mkdir) |
3294
|
149 |
3301
|
150 @DOCSTRING(rmdir) |
3294
|
151 |
3301
|
152 @DOCSTRING(mkfifo) |
3294
|
153 |
3301
|
154 @DOCSTRING(umask) |
3294
|
155 |
3301
|
156 @DOCSTRING(stat) |
3294
|
157 |
6549
|
158 @DOCSTRING(lstat) |
|
159 |
|
160 @DOCSTRING(fileattrib) |
|
161 |
|
162 @DOCSTRING(isdir) |
|
163 |
3301
|
164 @DOCSTRING(glob) |
3294
|
165 |
3428
|
166 @DOCSTRING(fnmatch) |
|
167 |
3301
|
168 @DOCSTRING(file_in_path) |
3294
|
169 |
3301
|
170 @DOCSTRING(tilde_expand) |
3294
|
171 |
6549
|
172 @DOCSTRING(canonicalize_file_name) |
|
173 |
|
174 @DOCSTRING(movefile) |
|
175 |
|
176 @DOCSTRING(copyfile) |
|
177 |
|
178 @DOCSTRING(fileparts) |
|
179 |
|
180 @DOCSTRING(filesep) |
|
181 |
|
182 @DOCSTRING(fullfile) |
|
183 |
|
184 @DOCSTRING(tempdir) |
|
185 |
|
186 @DOCSTRING(tempname) |
|
187 |
|
188 @DOCSTRING(P_tmpdir) |
|
189 |
|
190 @node File Archiving Utilities |
|
191 @section File Archiving Utilities |
|
192 |
|
193 @DOCSTRING(bunzip2) |
|
194 |
|
195 @DOCSTRING(gunzip) |
|
196 |
|
197 @DOCSTRING(tar) |
|
198 |
|
199 @DOCSTRING(untar) |
|
200 |
|
201 @DOCSTRING(zip) |
|
202 |
|
203 @DOCSTRING(unzip) |
|
204 |
|
205 @DOCSTRING(pack) |
|
206 |
|
207 @DOCSTRING(unpack) |
|
208 |
|
209 @node Networking Utilities |
|
210 @section Networking Utilities |
|
211 |
|
212 @DOCSTRING(urlread) |
|
213 |
|
214 @DOCSTRING(urlwrite) |
|
215 |
4167
|
216 @node Controlling Subprocesses |
3294
|
217 @section Controlling Subprocesses |
|
218 |
|
219 Octave includes some high-level commands like @code{system} and |
|
220 @code{popen} for starting subprocesses. If you want to run another |
|
221 program to perform some task and then look at its output, you will |
|
222 probably want to use these functions. |
|
223 |
|
224 Octave also provides several very low-level Unix-like functions which |
|
225 can also be used for starting subprocesses, but you should probably only |
|
226 use them if you can't find any way to do what you need with the |
|
227 higher-level functions. |
|
228 |
3301
|
229 @DOCSTRING(system) |
3294
|
230 |
6549
|
231 @DOCSTRING(unix) |
|
232 |
|
233 @DOCSTRING(dos) |
|
234 |
3301
|
235 @DOCSTRING(popen) |
3294
|
236 |
3301
|
237 @DOCSTRING(pclose) |
3294
|
238 |
3301
|
239 @DOCSTRING(popen2) |
3294
|
240 |
3301
|
241 @DOCSTRING(EXEC_PATH) |
3294
|
242 |
|
243 In most cases, the following functions simply decode their arguments and |
|
244 make the corresponding Unix system calls. For a complete example of how |
|
245 they can be used, look at the definition of the function @code{popen2}. |
|
246 |
3301
|
247 @DOCSTRING(fork) |
3294
|
248 |
3301
|
249 @DOCSTRING(exec) |
3294
|
250 |
3301
|
251 @DOCSTRING(pipe) |
3294
|
252 |
3301
|
253 @DOCSTRING(dup2) |
3294
|
254 |
3301
|
255 @DOCSTRING(waitpid) |
3294
|
256 |
3301
|
257 @DOCSTRING(fcntl) |
3294
|
258 |
6549
|
259 @DOCSTRING(kill) |
|
260 |
|
261 @DOCSTRING(SIG) |
|
262 |
4167
|
263 @node Process ID Information |
3294
|
264 @section Process, Group, and User IDs |
|
265 |
3301
|
266 @DOCSTRING(getpgrp) |
3294
|
267 |
3301
|
268 @DOCSTRING(getpid) |
3294
|
269 |
3301
|
270 @DOCSTRING(getppid) |
3294
|
271 |
3301
|
272 @DOCSTRING(geteuid) |
3294
|
273 |
3301
|
274 @DOCSTRING(getuid) |
3294
|
275 |
3301
|
276 @DOCSTRING(getegid) |
3294
|
277 |
3301
|
278 @DOCSTRING(getgid) |
3294
|
279 |
4167
|
280 @node Environment Variables |
3294
|
281 @section Environment Variables |
|
282 |
3301
|
283 @DOCSTRING(getenv) |
3294
|
284 |
3301
|
285 @DOCSTRING(putenv) |
3294
|
286 |
4167
|
287 @node Current Working Directory |
3294
|
288 @section Current Working Directory |
|
289 |
3301
|
290 @DOCSTRING(cd) |
3294
|
291 |
3301
|
292 @DOCSTRING(ls) |
3294
|
293 |
6549
|
294 @DOCSTRING(ls_command) |
|
295 |
|
296 @DOCSTRING(dir) |
|
297 |
3301
|
298 @DOCSTRING(pwd) |
3294
|
299 |
4167
|
300 @node Password Database Functions |
3294
|
301 @section Password Database Functions |
|
302 |
|
303 Octave's password database functions return information in a structure |
|
304 with the following fields. |
|
305 |
|
306 @table @code |
|
307 @item name |
|
308 The user name. |
|
309 |
|
310 @item passwd |
|
311 The encrypted password, if available. |
|
312 |
|
313 @item uid |
|
314 The numeric user id. |
|
315 |
|
316 @item gid |
|
317 The numeric group id. |
|
318 |
|
319 @item gecos |
|
320 The GECOS field. |
|
321 |
|
322 @item dir |
|
323 The home directory. |
|
324 |
|
325 @item shell |
|
326 The initial shell. |
|
327 @end table |
|
328 |
|
329 In the descriptions of the following functions, this data structure is |
|
330 referred to as a @var{pw_struct}. |
|
331 |
3301
|
332 @DOCSTRING(getpwent) |
3294
|
333 |
3301
|
334 @DOCSTRING(getpwuid) |
3294
|
335 |
3301
|
336 @DOCSTRING(getpwnam) |
3294
|
337 |
3301
|
338 @DOCSTRING(setpwent) |
3294
|
339 |
3301
|
340 @DOCSTRING(endpwent) |
3294
|
341 |
4167
|
342 @node Group Database Functions |
3294
|
343 @section Group Database Functions |
|
344 |
|
345 Octave's group database functions return information in a structure |
|
346 with the following fields. |
|
347 |
|
348 @table @code |
|
349 @item name |
|
350 The user name. |
|
351 |
|
352 @item passwd |
|
353 The encrypted password, if available. |
|
354 |
|
355 @item gid |
|
356 The numeric group id. |
|
357 |
|
358 @item mem |
|
359 The members of the group. |
|
360 @end table |
|
361 |
|
362 In the descriptions of the following functions, this data structure is |
|
363 referred to as a @var{grp_struct}. |
|
364 |
3301
|
365 @DOCSTRING(getgrent) |
3294
|
366 |
3301
|
367 @DOCSTRING(getgrgid) |
|
368 |
|
369 @DOCSTRING(getgrnam) |
3294
|
370 |
3301
|
371 @DOCSTRING(setgrent) |
3294
|
372 |
3301
|
373 @DOCSTRING(endgrent) |
3294
|
374 |
4167
|
375 @node System Information |
3294
|
376 @section System Information |
|
377 |
3301
|
378 @DOCSTRING(computer) |
3294
|
379 |
6549
|
380 @DOCSTRING(uname) |
|
381 |
|
382 @DOCSTRING(ispc) |
|
383 |
|
384 @DOCSTRING(isunix) |
|
385 |
3301
|
386 @DOCSTRING(isieee) |
3294
|
387 |
3301
|
388 @DOCSTRING(OCTAVE_VERSION) |
3294
|
389 |
3301
|
390 @DOCSTRING(octave_config_info) |
3294
|
391 |
3301
|
392 @DOCSTRING(getrusage) |