<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">The “Shell Out” package’s source code shows some simple usage of Foundation’s Process: <a href="https://github.com/JohnSundell/ShellOut/blob/master/Sources/ShellOut.swift#L33" class="">https://github.com/JohnSundell/ShellOut/blob/master/Sources/ShellOut.swift#L33</a>.&nbsp;</div><div class=""><br class=""></div><div class="">That package also handles stdout / stdin, but for more sophisticated uses of FileManager the “Files” package’s source has some nice simple usage:&nbsp;<a href="https://github.com/JohnSundell/Files/blob/master/Sources/Files.swift" class="">https://github.com/JohnSundell/Files/blob/master/Sources/Files.swift</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 4, 2018, at 10:31 AM, Karl Wagner via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">These kinds of things live in Foundation, not the standard library:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><font face="Courier" class="">import Foundation</font><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">let p = Process()</font></div><div class=""><font face="Courier" class="">p.executableURL = URL(fileURLWithPath: "/bin/ps")</font></div><div class=""><font face="Courier" class="">try p.run()</font></div></blockquote><div class=""><br class=""></div><div class="">The Process class provides you with stdin/out/error handles for the process (<a href="https://developer.apple.com/documentation/foundation/process" class="">https://developer.apple.com/documentation/foundation/process</a>).</div><div class="">FileHandle also provides these standard streams for the current process (<a href="https://developer.apple.com/documentation/foundation/filehandle" class="">https://developer.apple.com/documentation/foundation/filehandle</a>).</div><div class=""><br class=""></div><div class="">- Karl<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 4. Jan 2018, at 17:03, Седых Александр via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">
<div class=""><p style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" data-mce-style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" class="">Well, for example in Python we can run another program from interpreter by</p><div style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; color: rgb(69, 69, 69); min-height: 14px;" class="">&nbsp;<br class="webkit-block-placeholder"></div><p style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" data-mce-style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" class="">import subprocess</p><p style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" data-mce-style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" class="">result = subprocess.run('ruby script.rb').stdout</p><div style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; color: rgb(69, 69, 69); min-height: 14px;" class="">&nbsp;<br class="webkit-block-placeholder"></div><p style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" data-mce-style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" class="">My question is next:</p><p style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" data-mce-style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" class="">Can we do something from Swift file at runtime or maybe from terminal via REPL</p><div style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; color: rgb(69, 69, 69); min-height: 14px;" class="">&nbsp;<br class="webkit-block-placeholder"></div><p style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" data-mce-style="margin-bottom: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: #454545;" class="">And can you send me resource when I can read about work with stdin, stdout in Swift, because is very small info in Documentation (Standard Library I/O)</p><br class="">-<br class="">Alexandr</div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>