<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Calling External Programs' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Calling External Programs' posted on the 'Ruby' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 06:44:12 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 06:44:12 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Calling External Programs</title>
      <link>http://www.programmersheaven.com/mb/ruby/394669/394669/calling-external-programs/</link>
      <description>I am writing a series of scripts that run and use output from a variety of network tools. What tools and what arguments will be determined at runtime, and these arguments can get complex. For example running nmap -PA -sV -O -T4 -p80,443,8080,8443,9000-10000 &amp;lt;target&amp;gt;. If the target and arguments are know before running it, it is simple, either use `...` or %x{...}, but this method seems to not take string parameters only literals, using system makes it impossible to capture output which is what I need to do. I am using open3 which works but doesn't seem to be ideal. I would like to have to be free from constructing the complete command line string, but this is the only thing that seems to work.&lt;br /&gt;
&lt;br /&gt;
If I try:&lt;br /&gt;
inp,out,err = popen3(@tool, @args)&lt;br /&gt;
inp.puts @target&lt;br /&gt;
inp.close&lt;br /&gt;
It works with one argument, but not multiple. This would be perfect because I will likely have a list of targets, but arguments may change based on other runtime criteria. The problem is that this only works with 1 argument, passing in multiple arguments as either a single string or many arguments results in failure: either a broken pipe or nmap can't see the target. So my solution is to build a single string and pass that:&lt;br /&gt;
&lt;br /&gt;
inp,out,err = popen3(@tool)&lt;br /&gt;
inp.close&lt;br /&gt;
&lt;br /&gt;
Where @tool is something like 'nmap -PA -sV -O -T4 -p80,443,8080,8443,9000-10000 &amp;lt;target&amp;gt;'. Is there a better way to accomplish this? This works but having to build a lot strings during runtime is going to slow things down considerably as I may have hundreds of targets and a dozen or more tools to run and parse data from.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ruby/394669/394669/calling-external-programs/</guid>
      <pubDate>Tue, 04 Aug 2009 17:40:54 -0700</pubDate>
      <category>Ruby</category>
    </item>
    <item>
      <title>This post has been deleted.</title>
      <link>http://www.programmersheaven.com/mb/ruby/394669/409174/this-post-has-been-deleted/#409174</link>
      <description>This post has been deleted.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ruby/394669/409174/this-post-has-been-deleted/#409174</guid>
      <pubDate>Thu, 12 Nov 2009 11:02:29 -0700</pubDate>
      <category>Ruby</category>
    </item>
  </channel>
</rss>