AbstractOperatingSystem.st
changeset 17001 0524ca8f7a55
parent 16968 cde6c2e2e9be
child 17002 41fd1e27f184
--- a/AbstractOperatingSystem.st	Sat Nov 08 10:35:08 2014 +0100
+++ b/AbstractOperatingSystem.st	Sat Nov 08 11:16:32 2014 +0100
@@ -1218,6 +1218,82 @@
     "Modified: / 10.11.1998 / 20:54:37 / cg"
 !
 
+executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream
+    "execute the unix command specified by the argument, aCommandString.
+     The commandString is passed to a shell for execution - see the description of
+     'sh -c' in your UNIX manual.
+     Return true if successful, false if not."
+
+    ^ self
+        executeCommand:aCommandString
+        inputFrom:anInStream
+        outputTo:anOutStream
+        errorTo:anErrStream
+        auxFrom:nil
+        environment:nil
+        inDirectory:nil
+        lineWise:false
+        onError:[:status | false]
+
+    "
+        OperatingSystem
+            executeCommand:'ls'
+            inputFrom:nil
+            outputTo:Transcript
+            errorTo:Transcript        
+
+        |s|
+        s := WriteStream on:''.
+        (OperatingSystem
+            executeCommand:'ls'
+            inputFrom:nil
+            outputTo:s
+            errorTo:Transcript) ifTrue:[Transcript showCR:s contents]        
+
+        OperatingSystem
+            executeCommand:'dir'
+            inputFrom:nil
+            outputTo:Transcript
+            errorTo:Transcript
+
+        OperatingSystem
+            executeCommand:'foo'
+            inputFrom:Transcript
+            outputTo:Transcript
+            errorTo:nil
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls /fooBar'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+
+    "Modified: / 10.11.1998 / 20:51:39 / cg"
+!
+
 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream
     errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
     inDirectory:dirOrNil lineWise:lineWise onError:aBlock
@@ -7523,11 +7599,11 @@
 !AbstractOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.272 2014-11-07 17:49:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.273 2014-11-08 10:16:32 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.272 2014-11-07 17:49:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.273 2014-11-08 10:16:32 cg Exp $'
 ! !