<?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: system() command fails on HP-UX PARISC 11iv3 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613033#M675596</link>
    <description>Alright!&lt;BR /&gt;I'll try with tusc or gdb.&lt;BR /&gt;&lt;BR /&gt;Many thanks to all of you.&lt;BR /&gt;&lt;BR /&gt;--Shikha</description>
    <pubDate>Thu, 08 Apr 2010 04:04:45 GMT</pubDate>
    <dc:creator>ShikhaMaheshwari</dc:creator>
    <dc:date>2010-04-08T04:04:45Z</dc:date>
    <item>
      <title>system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613023#M675586</link>
      <description>Hi,&lt;BR /&gt;when we execute system() command (as follows) in the application, it gives following error:&lt;BR /&gt;&lt;BR /&gt;command syntax used in application code:&lt;BR /&gt;system ("ps -eaf | grep ssh");&lt;BR /&gt;&lt;BR /&gt;error:&lt;BR /&gt;sh: ps:  not found.&lt;BR /&gt;sh: grep:  not found.&lt;BR /&gt;&lt;BR /&gt;But if I test this with a sample program as:&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; system ("ps -eaf | grep ssh");&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;It works fine.&lt;BR /&gt;Can anyone tell, what could be the reasons of the failure and why does it show different behavior? &lt;BR /&gt;&lt;BR /&gt;NOTE: In application we are not doing any such operation which can disturb the shell environment.&lt;BR /&gt;&lt;BR /&gt;Other Information:&lt;BR /&gt;------------------&lt;BR /&gt;# uname -a&lt;BR /&gt;HP-UX islrppss B.11.31 U 9000/800 936132380 unlimited-user license&lt;BR /&gt;&lt;BR /&gt;# aCC -V&lt;BR /&gt;aCC: HP ANSI C++ B3910B A.03.80&lt;BR /&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 06 Apr 2010 20:31:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613023#M675586</guid>
      <dc:creator>ShikhaMaheshwari</dc:creator>
      <dc:date>2010-04-06T20:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613024#M675587</link>
      <description>&lt;!--!*#--&gt;&amp;gt; sh: ps: not found.&lt;BR /&gt;&lt;BR /&gt;Apparently, system() is running "sh" as it&lt;BR /&gt;should, but "sh" is not finding "ps".  I'd&lt;BR /&gt;guess that there's a problem with PATH in the&lt;BR /&gt;problem environment.&lt;BR /&gt;&lt;BR /&gt;An easy (if not very portable) way out might&lt;BR /&gt;be to specify absolute paths to "ps" and&lt;BR /&gt;"grep" in your argument string.&lt;BR /&gt;&lt;BR /&gt;To explore, you might throw in something&lt;BR /&gt;like:&lt;BR /&gt;&lt;BR /&gt;      system( "echo $PATH");&lt;BR /&gt;&lt;BR /&gt;and see what that says.</description>
      <pubDate>Tue, 06 Apr 2010 20:46:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613024#M675587</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-06T20:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613025#M675588</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This suggests that your application's PATH doesn't contain '/usr/bin'.&lt;BR /&gt;&lt;BR /&gt;You might fix your application to do"&lt;BR /&gt;&lt;BR /&gt;# system ("/usr/bin/ps -eaf | grep /usr/bin/ssh");&lt;BR /&gt;&lt;BR /&gt;...instead of:&lt;BR /&gt;&lt;BR /&gt;# system ("ps -eaf | grep ssh");&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Apr 2010 20:48:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613025#M675588</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-04-06T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613026#M675589</link>
      <description>&lt;!--!*#--&gt;&amp;gt; # system ("/usr/bin/ps -eaf | grep /usr/bin/ssh");&lt;BR /&gt;&lt;BR /&gt;That may not help it to find "grep", but it&lt;BR /&gt;could damage basic functionality.  (If you've&lt;BR /&gt;seen one path, you've seen them all, I always&lt;BR /&gt;say.)</description>
      <pubDate>Tue, 06 Apr 2010 21:25:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613026#M675589</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-06T21:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613027#M675590</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;OK, stupid typo as Steven pointed out:&lt;BR /&gt;&lt;BR /&gt;I wrote:&lt;BR /&gt;&lt;BR /&gt;# system ("/usr/bin/ps -eaf | grep /usr/bin/ssh");&lt;BR /&gt;&lt;BR /&gt;But should have written:&lt;BR /&gt;&lt;BR /&gt;# system ("/usr/bin/ps -eaf | /usr/bin/grep /usr/bin/ssh");&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Apr 2010 22:06:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613027#M675590</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-04-06T22:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613028#M675591</link>
      <description>&amp;gt;system ("ps -eaf | grep ssh"); &lt;BR /&gt;&lt;BR /&gt;As an optimization, you could toss that grep:&lt;BR /&gt;system("UNIX95=EXTENDED_PS /usr/bin/ps -af -C ssh")&lt;BR /&gt;Provided you don't care about -a exclusions.&lt;BR /&gt;Otherwise you might want to use: /usr/bin/grep -w ssh</description>
      <pubDate>Tue, 06 Apr 2010 22:37:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613028#M675591</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-04-06T22:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613029#M675592</link>
      <description>&lt;!--!*#--&gt;&amp;gt; OK, stupid typo [...]&lt;BR /&gt;&lt;BR /&gt;Not every error is a typographical error.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; But should have written:&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; # system ("/usr/bin/ps -eaf | /usr/bin/grep /usr/bin/ssh");&lt;BR /&gt;&lt;BR /&gt;Why "/usr/bin/ssh" instead of "ssh"?</description>
      <pubDate>Tue, 06 Apr 2010 22:48:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613029#M675592</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-06T22:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613030#M675593</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Steven: Why "/usr/bin/ssh" instead of "ssh"?&lt;BR /&gt;&lt;BR /&gt;OMG, I have failed to multitask during dinner :-(  Yes, yes, I mean use *absolute* paths to your executables' only (although that should have been somewhat obvious from my *first* post's commentary (minus the bungled code corrected below):&lt;BR /&gt;&lt;BR /&gt;# system ("/usr/bin/ps -eaf | /usr/bin/grep ssh");&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 06 Apr 2010 23:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613030#M675593</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-04-06T23:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613031#M675594</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;yes, it works in the following way:&lt;BR /&gt;system("/usr/bin/ps -eaf|/usr/bin/grep ssh");&lt;BR /&gt;&lt;BR /&gt;But I do not want to use in this way. It works fine on other platforms(Liux, Solaris) in the same way but not on HP.&lt;BR /&gt;&lt;BR /&gt;As per your suggestion, I printed PATH before calling system() in the application code as:&lt;BR /&gt;&lt;BR /&gt;system("echo $PATH");&lt;BR /&gt;system("ps -eaf|grep ssh");&lt;BR /&gt;&lt;BR /&gt;PATH shows the correct output. It has all the required ones like:&lt;BR /&gt;&lt;BR /&gt;/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/usr/sbin:/usr/bin:/opt/ansic/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/opt/ipf/bin:/opt/nettladm/bin:/opt/fcms/bin:/opt/wbem/bin:/opt/firefox:/opt/gnome/bin:.....&lt;BR /&gt;&lt;BR /&gt;Then also the error occurs.&lt;BR /&gt;sh : ps : not found&lt;BR /&gt;sh : grep : not found&lt;BR /&gt;&lt;BR /&gt;It would be highly appreciable if anyone can help me to find out the root cause of this failure.&lt;BR /&gt;&lt;BR /&gt;Many Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;-Shikha</description>
      <pubDate>Wed, 07 Apr 2010 09:53:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613031#M675594</guid>
      <dc:creator>ShikhaMaheshwari</dc:creator>
      <dc:date>2010-04-07T09:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613032#M675595</link>
      <description>&amp;gt;It works fine on other platforms in the same way but not on HP-UX.&lt;BR /&gt;&lt;BR /&gt;You said it worked in a small example, so there is something special about your application.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I printed PATH before calling system() in the application code as:&lt;BR /&gt;system("echo $PATH");&lt;BR /&gt;system("ps -eaf|grep ssh");&lt;BR /&gt;&lt;BR /&gt;Hmm, that seems right.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;It has all the required ones like:&lt;BR /&gt;/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/usr/sbin:/usr/bin:...&lt;BR /&gt;&lt;BR /&gt;You may want to put /usr/bin first.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;It would be highly appreciable if anyone can help me to find out the root cause of this failure.&lt;BR /&gt;&lt;BR /&gt;Unfortunately it seems you need to be looking for zebras. ;-)&lt;BR /&gt;&lt;BR /&gt;You could use tusc to see what your application is doing with the environ(5):&lt;BR /&gt;tusc -fp -ea -o tusc.out application parms ...&lt;BR /&gt;&lt;BR /&gt;And attach the resulting tusc.out if it isn't too big.&lt;BR /&gt;Otherwise look for sections doing fork/exec of /usr/bin/sh.</description>
      <pubDate>Wed, 07 Apr 2010 13:59:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613032#M675595</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-04-07T13:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: system() command fails on HP-UX PARISC 11iv3</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613033#M675596</link>
      <description>Alright!&lt;BR /&gt;I'll try with tusc or gdb.&lt;BR /&gt;&lt;BR /&gt;Many thanks to all of you.&lt;BR /&gt;&lt;BR /&gt;--Shikha</description>
      <pubDate>Thu, 08 Apr 2010 04:04:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/system-command-fails-on-hp-ux-parisc-11iv3/m-p/4613033#M675596</guid>
      <dc:creator>ShikhaMaheshwari</dc:creator>
      <dc:date>2010-04-08T04:04:45Z</dc:date>
    </item>
  </channel>
</rss>

