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