268 " |
268 " |
269 |
269 |
270 "Modified: 24.4.1996 / 09:09:25 / stefan" |
270 "Modified: 24.4.1996 / 09:09:25 / stefan" |
271 ! |
271 ! |
272 |
272 |
|
273 readingFrom:commandString errorDisposition:handleError inDirectory:aDirectory |
|
274 "similar to #readingFrom, but changes the directory while |
|
275 executing the command. Use this if a command is to be |
|
276 executed in another directory, to avoid any OS dependencies |
|
277 in your code. |
|
278 handleError may be one of #discard #inline #stderr (default), which causes |
|
279 stderr to me discarded (/dev/null), merged into the PipeStream or written |
|
280 to smalltalks stderr." |
|
281 |
|
282 |cmd tmpComFile pipe| |
|
283 |
|
284 (OperatingSystem platformName == #vms) ifTrue:[ |
|
285 tmpComFile := OperatingSystem createCOMFileForVMSCommand:commandString in:aDirectory. |
|
286 cmd := '@' , tmpComFile osName. |
|
287 pipe := self readingFrom:cmd. |
|
288 pipe notNil ifTrue:[ |
|
289 pipe exitAction:[tmpComFile delete]. |
|
290 ]. |
|
291 ^ pipe |
|
292 ]. |
|
293 |
|
294 "/ unix - prepend a 'cd' to the command |
|
295 cmd := 'cd ' , aDirectory asFilename pathName, '; ' , commandString. |
|
296 handleError == #discard ifTrue:[ |
|
297 cmd := cmd, ' 2>/dev/null'. |
|
298 ] ifFalse:[handleError == #inline ifTrue:[ |
|
299 cmd := cmd, ' 2>&1'. |
|
300 ]]. |
|
301 ^ self readingFrom:cmd |
|
302 |
|
303 "Created: 24.9.1997 / 09:32:35 / stefan" |
|
304 ! |
|
305 |
273 readingFrom:commandString inDirectory:aDirectory |
306 readingFrom:commandString inDirectory:aDirectory |
274 "similar to #readingFrom, but changes the directory while |
307 "similar to #readingFrom, but changes the directory while |
275 executing the command. Use this if a command is to be |
308 executing the command. Use this if a command is to be |
276 executed in another directory, to avoid any OS dependencies |
309 executed in another directory, to avoid any OS dependencies |
277 in your code." |
310 in your code." |
278 |
311 |
279 |cmd tmpComFile pipe| |
312 ^ self readingFrom:commandString errorDisposition:#stderr inDirectory:aDirectory |
280 |
313 |
281 (OperatingSystem platformName == #vms) ifTrue:[ |
314 "Modified: 24.9.1997 / 09:33:48 / stefan" |
282 tmpComFile := OperatingSystem createCOMFileForVMSCommand:commandString in:aDirectory. |
|
283 cmd := '@' , tmpComFile osName. |
|
284 pipe := self readingFrom:cmd. |
|
285 pipe notNil ifTrue:[ |
|
286 pipe exitAction:[tmpComFile delete]. |
|
287 ]. |
|
288 ^ pipe |
|
289 ]. |
|
290 |
|
291 "/ unix - prepend a 'cd' to the command |
|
292 cmd := 'cd ' , aDirectory asFilename pathName, '; ' , commandString. |
|
293 ^ self readingFrom:cmd |
|
294 ! |
315 ! |
295 |
316 |
296 writingTo:commandString |
317 writingTo:commandString |
297 "create and return a new pipeStream which can write to the unix command |
318 "create and return a new pipeStream which can write to the unix command |
298 given by command." |
319 given by command." |