<?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 capture pid from process started by su command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244937#M714698</link>
    <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I have a script that starts custom applications as a particular user.  Is it possible to start a program via su and capture the pid of program just started?&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;su someuser -c "proga.exe &amp;amp;"&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Scott</description>
    <pubDate>Sat, 10 Apr 2004 16:33:51 GMT</pubDate>
    <dc:creator>Scott Williams_5</dc:creator>
    <dc:date>2004-04-10T16:33:51Z</dc:date>
    <item>
      <title>capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244937#M714698</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I have a script that starts custom applications as a particular user.  Is it possible to start a program via su and capture the pid of program just started?&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;su someuser -c "proga.exe &amp;amp;"&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Sat, 10 Apr 2004 16:33:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244937#M714698</guid>
      <dc:creator>Scott Williams_5</dc:creator>
      <dc:date>2004-04-10T16:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244938#M714699</link>
      <description>well $! gives you the pid of the last process started in the background, so as long as you redirect all other output, you could do domthing like this&lt;BR /&gt;&lt;BR /&gt;pid=$(su someuser -c "proga.exe &amp;gt;/tmp/proga.output.log 2&amp;gt;&amp;amp;1 &amp;amp;  ; echo $?" )&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;BR /&gt;</description>
      <pubDate>Sat, 10 Apr 2004 17:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244938#M714699</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2004-04-10T17:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244939#M714700</link>
      <description>oops, of course that should have been:&lt;BR /&gt;&lt;BR /&gt;pid=$(su someuser -c "proga.exe &amp;gt;/tmp/proga.output.log 2&amp;gt;&amp;amp;1 &amp;amp; ; echo $!" )&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Sun, 11 Apr 2004 03:36:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244939#M714700</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2004-04-11T03:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244940#M714701</link>
      <description>you can grep for program name, excluding the grep command &lt;BR /&gt;&lt;BR /&gt;progname=$1&lt;BR /&gt;PID=`ps -ef | grep $progname | grep -v grep | awk '{print $2}'`</description>
      <pubDate>Mon, 12 Apr 2004 06:26:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244940#M714701</guid>
      <dc:creator>Renda Skandier</dc:creator>
      <dc:date>2004-04-12T06:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244941#M714702</link>
      <description>Thank you for your responses.  I'm sorry I've taken so long to reply...I have tried your suggestion, and am running into a bit of a snag.  The "echo $!" is not returning a value. I've attached a snippit of code and the output I get back..&lt;BR /&gt;&lt;BR /&gt;Appreciate your help.&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Mon, 12 Apr 2004 14:45:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244941#M714702</guid>
      <dc:creator>Scott Williams_5</dc:creator>
      <dc:date>2004-04-12T14:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244942#M714703</link>
      <description>The only way I see to make this work in this manner is to put your commands in a wrapper script that would be called from su. I haven't found a syntax that will allow running multiple commands in a single line from su with the semicolon.</description>
      <pubDate>Mon, 12 Apr 2004 15:44:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244942#M714703</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2004-04-12T15:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: capture pid from process started by su command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244943#M714704</link>
      <description>Jeff, Duncan, Renda: Thanks for your repsones.  Given my trials, I suspected I'd have to something similar to a separate script.  I'm movin' on...&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Mon, 12 Apr 2004 16:15:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-pid-from-process-started-by-su-command/m-p/3244943#M714704</guid>
      <dc:creator>Scott Williams_5</dc:creator>
      <dc:date>2004-04-12T16:15:48Z</dc:date>
    </item>
  </channel>
</rss>

