#FEATURE
authorClaus Gittinger <cg@exept.de>
Mon, 28 Mar 2016 15:16:49 +0200
changeset 19491 9c451dfc5949
parent 19490 4d29d49edd98
child 19492 8422ce672a77
#FEATURE class: AbstractOperatingSystem added: #executeCommand:outputTo:errorTo:
AbstractOperatingSystem.st
--- a/AbstractOperatingSystem.st	Mon Mar 28 13:20:31 2016 +0200
+++ b/AbstractOperatingSystem.st	Mon Mar 28 15:16:49 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -1930,6 +1932,40 @@
     "
 !
 
+executeCommand:aCommandString outputTo:anOutStreamOrNil errorTo:anErrStreamOrNil
+    "execute the unix command specified by the argument, aCommandString.
+     If aCommandString is a String, the commandString is passed to a shell for execution
+     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
+     If aCommandString is an Array, the first element is the command to be executed,
+     and the other elements are the arguments to the command. No shell is invoked in this case.
+     Return true if successful, false otherwise."
+
+     ^ self
+        executeCommand:aCommandString
+        inputFrom:nil
+        outputTo:anOutStreamOrNil
+        errorTo:anErrStreamOrNil
+        auxFrom:nil
+        environment:nil
+        inDirectory:nil
+        lineWise:false
+        onError:[:status| false]
+
+    "
+     String streamContents:[:s|OperatingSystem
+        executeCommand:'ls'
+        outputTo:s
+     ]
+    "
+
+    "
+     String streamContents:[:s|OperatingSystem
+        executeCommand:'pwd'
+        outputTo:s
+     ]
+    "
+!
+
 executeCommand:aCommandString outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:aDirectory
     "much like #executeCommand:, but changes the current directory
      for the command. Since this is OS specific, use this instead of