AbstractOperatingSystem.st
branchjv
changeset 19496 7613c0fb5f3c
parent 19431 3e697e4bcbf5
parent 19491 9c451dfc5949
child 19637 aceade7525bb
--- a/AbstractOperatingSystem.st	Sat Mar 26 07:56:10 2016 +0000
+++ b/AbstractOperatingSystem.st	Tue Mar 29 08:38:24 2016 +0100
@@ -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