Multiple commands exec

blov · · 486 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>How can i run multiple and concat commands in go? Is there a way to do that with the exec lib?</p> <hr/>**评论:**<br/><br/>rjik: <pre><p>You can just use plain os/exec and pipe commands by setting (*exec.Cmd).Std* fields. There are also higher level wrappers like <a href="https://labix.org/pipe" rel="nofollow">https://labix.org/pipe</a>.</p></pre>nathj07: <pre><p>I wonder what the desired outcome is a there may be a better approach available. Are you able to outline what you want to achieve?</p></pre>cs-guy: <pre><p><a href="http://labix.org/pipe" rel="nofollow">http://labix.org/pipe</a></p></pre>DongerDave: <pre><p>Your question shows that you shouldn&#39;t be trusted to run commands because you clearly don&#39;t understand what they are or how they work.</p> <p>You can run multiple commands by using <code>exec.Command</code> multiple times.</p> <p>You can <code>&amp;&amp;</code> or <code>;</code> or <code>|</code> commands together (the former two of those are not command things, but shell things) by doing an exec.Command of something like <code>sh -c &#34;my command &amp;&amp; my other command || my third command; my final command&#34;</code>. The go stdlibrary already can do piping with some difficulty.</p> <p>Next time, consider googling or thinking for 5 seconds before spamming up a forum.</p></pre>eriken: <pre><p>What are you talking about? ofcource you can exec concurrently just have them write to the same channel.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

486 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传