<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to read piped commands with JAVA in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479967#M680372</link>
    <description>&lt;!--!*#--&gt;&amp;gt; I don't do Java (as we say). [...]&lt;BR /&gt;&lt;BR /&gt;A long time ago, I looked at some Java code&lt;BR /&gt;for several minutes, so I still know nothing.&lt;BR /&gt;&lt;BR /&gt;My theory is that the pipeline ("|") symbol&lt;BR /&gt;means something to a shell, not to lsof.&lt;BR /&gt;Therefore, if Runtime.getRuntime().exec uses&lt;BR /&gt;something in the execl()/execv() category,&lt;BR /&gt;then I'd expect all this stuff to be passed&lt;BR /&gt;into lsof, which might become confused and/or&lt;BR /&gt;unhappy.  Java syntax aside, my plan is to&lt;BR /&gt;run a shell, to whom the pipeline ("|") makes&lt;BR /&gt;some sense, and pass it the (shell) command&lt;BR /&gt;which works so well when used interactively&lt;BR /&gt;(that is, when you give that command to a&lt;BR /&gt;shell).&lt;BR /&gt;&lt;BR /&gt;One advantage to all these new programming&lt;BR /&gt;languages is that they make it easy to write&lt;BR /&gt;code while having no idea what the computer&lt;BR /&gt;is actually doing.  Starting on a Univac 422&lt;BR /&gt;is obviously a superior method, which I&lt;BR /&gt;recommend to one and all.  (There's very&lt;BR /&gt;little magic in a system with 512 15-bit&lt;BR /&gt;words of core memory.)</description>
    <pubDate>Fri, 14 Aug 2009 23:00:27 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2009-08-14T23:00:27Z</dc:date>
    <item>
      <title>How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479963#M680368</link>
      <description>PA-RISC RP3410&lt;BR /&gt;java6&lt;BR /&gt;&lt;BR /&gt;I'd like to perform the following unix command from Java:&lt;BR /&gt;&lt;BR /&gt;lsof -P|grep TCP&lt;BR /&gt;&lt;BR /&gt;I'm using:&lt;BR /&gt;Process process = Runtime.getRuntime().exec( "lsof -P|grep TCP" );&lt;BR /&gt;&lt;BR /&gt;but I get no output, only if I remove grep.&lt;BR /&gt;&lt;BR /&gt;TIA for your help.&lt;BR /&gt;&lt;BR /&gt;Juan.</description>
      <pubDate>Fri, 14 Aug 2009 19:56:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479963#M680368</guid>
      <dc:creator>JUAN VIDAL_1</dc:creator>
      <dc:date>2009-08-14T19:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479964#M680369</link>
      <description>&lt;!--!*#--&gt;I know nothing, but have you tried anything&lt;BR /&gt;like this:?&lt;BR /&gt;&lt;BR /&gt;[...]exec( "sh -c 'lsof -P|grep TCP'" );&lt;BR /&gt;&lt;BR /&gt;That may need to look more like this:&lt;BR /&gt;&lt;BR /&gt;[...]exec( { "sh", "-c", "'lsof -P|grep TCP'" } );</description>
      <pubDate>Fri, 14 Aug 2009 21:26:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479964#M680369</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-08-14T21:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479965#M680370</link>
      <description>Hi Juan:&lt;BR /&gt;&lt;BR /&gt;I don't do Java (as we say).  However, in other languages, the lvalue of the system() call would return the status of the call, not the results.&lt;BR /&gt;&lt;BR /&gt;Perhaps this helps:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.devdaily.com/java/edu/pj/pj010016/pj010016.shtml" target="_blank"&gt;http://www.devdaily.com/java/edu/pj/pj010016/pj010016.shtml&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 14 Aug 2009 21:42:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479965#M680370</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-14T21:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479966#M680371</link>
      <description>&amp;gt;JRF: the value of the system() call would return the status of the call, not the results.&lt;BR /&gt;&lt;BR /&gt;Right.  The results would go to stdout/stderr or to a redirected file.</description>
      <pubDate>Fri, 14 Aug 2009 22:21:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479966#M680371</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-08-14T22:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479967#M680372</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I don't do Java (as we say). [...]&lt;BR /&gt;&lt;BR /&gt;A long time ago, I looked at some Java code&lt;BR /&gt;for several minutes, so I still know nothing.&lt;BR /&gt;&lt;BR /&gt;My theory is that the pipeline ("|") symbol&lt;BR /&gt;means something to a shell, not to lsof.&lt;BR /&gt;Therefore, if Runtime.getRuntime().exec uses&lt;BR /&gt;something in the execl()/execv() category,&lt;BR /&gt;then I'd expect all this stuff to be passed&lt;BR /&gt;into lsof, which might become confused and/or&lt;BR /&gt;unhappy.  Java syntax aside, my plan is to&lt;BR /&gt;run a shell, to whom the pipeline ("|") makes&lt;BR /&gt;some sense, and pass it the (shell) command&lt;BR /&gt;which works so well when used interactively&lt;BR /&gt;(that is, when you give that command to a&lt;BR /&gt;shell).&lt;BR /&gt;&lt;BR /&gt;One advantage to all these new programming&lt;BR /&gt;languages is that they make it easy to write&lt;BR /&gt;code while having no idea what the computer&lt;BR /&gt;is actually doing.  Starting on a Univac 422&lt;BR /&gt;is obviously a superior method, which I&lt;BR /&gt;recommend to one and all.  (There's very&lt;BR /&gt;little magic in a system with 512 15-bit&lt;BR /&gt;words of core memory.)</description>
      <pubDate>Fri, 14 Aug 2009 23:00:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479967#M680372</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-08-14T23:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479968#M680373</link>
      <description>exec( "sh -c 'lsof -P|grep TCP'" ) &lt;BR /&gt;gets no output.&lt;BR /&gt;&lt;BR /&gt;Guess java VM just process one proc at shell...</description>
      <pubDate>Tue, 18 Aug 2009 13:47:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479968#M680373</guid>
      <dc:creator>JUAN VIDAL_1</dc:creator>
      <dc:date>2009-08-18T13:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479969#M680374</link>
      <description>did you try doing it the poor man's pipe way, i.e., creating intermediary files yourself, instead of relying on the OS ?&lt;BR /&gt;&lt;BR /&gt;exec( "sh -c 'lsof -P &amp;gt;/tmp/some_temp_file'" )&lt;BR /&gt;exec( "sh -c 'grep TCP /tmp/some_temp_file'" )&lt;BR /&gt;exec( "sh -c 'rm /tmp/some_temp_file'")&lt;BR /&gt;&lt;BR /&gt;I know it is not the most elegant way of doing it or most efficient, I can even guarantee it is a resource hog by launching series exec calls, but if you are not going to execute your java code continuously, you can absorb the performance penalty. &lt;BR /&gt;&lt;BR /&gt;Just a suggestion, otherwise, I am not a java programmer neither. Quoting JRF "I don't do anything with word JAVA in it" other than drinking copious amounts of Java everyday :)</description>
      <pubDate>Tue, 18 Aug 2009 14:14:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479969#M680374</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-08-18T14:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to read piped commands with JAVA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479970#M680375</link>
      <description>&amp;gt;Mel: did you try doing it the poor man's pipe way, i.e., creating intermediary files yourself, instead of relying on the OS?&lt;BR /&gt;&lt;BR /&gt;(This doesn't use the OS, but the shell.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;exec("sh -c 'lsof -P &amp;gt;/tmp/some_temp_file'")&lt;BR /&gt;&lt;BR /&gt;If you invoke sh, you can use a pipe.</description>
      <pubDate>Tue, 18 Aug 2009 15:08:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-read-piped-commands-with-java/m-p/4479970#M680375</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-08-18T15:08:30Z</dc:date>
    </item>
  </channel>
</rss>

