<?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 Perl script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257830#M714883</link>
    <description>&lt;BR /&gt;Please help me. &lt;BR /&gt;I need a secure way using Perl to check&lt;BR /&gt;whether the another example of main program is in the memory like process.&lt;BR /&gt;If another example is running,then not to start the program, else - to start.&lt;BR /&gt;But without using system("ps -ef | grep myprogram").&lt;BR /&gt;I need a clearly Perl-example.&lt;BR /&gt;  Thanks for help.</description>
    <pubDate>Fri, 23 Apr 2004 11:03:17 GMT</pubDate>
    <dc:creator>svilen888</dc:creator>
    <dc:date>2004-04-23T11:03:17Z</dc:date>
    <item>
      <title>Perl script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257830#M714883</link>
      <description>&lt;BR /&gt;Please help me. &lt;BR /&gt;I need a secure way using Perl to check&lt;BR /&gt;whether the another example of main program is in the memory like process.&lt;BR /&gt;If another example is running,then not to start the program, else - to start.&lt;BR /&gt;But without using system("ps -ef | grep myprogram").&lt;BR /&gt;I need a clearly Perl-example.&lt;BR /&gt;  Thanks for help.</description>
      <pubDate>Fri, 23 Apr 2004 11:03:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257830#M714883</guid>
      <dc:creator>svilen888</dc:creator>
      <dc:date>2004-04-23T11:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257831#M714884</link>
      <description>Probably the most straightforward method is as your script starts, check for the existence of a file; e.g. /var/tmp/mygrogram.pid&lt;BR /&gt;&lt;BR /&gt;If the file does not exist, then it is safe to continue. You create the file and write the PID of your current process into the file. Upon exit, remove the file.&lt;BR /&gt;&lt;BR /&gt;If the file does exist, read the contents of the file to get the PID of the process that wrote it. &lt;BR /&gt;send a kill 0 to this process.&lt;BR /&gt;$rslt = kill 0,$other_pid;&lt;BR /&gt;if ($rslt)&lt;BR /&gt;  {&lt;BR /&gt;    exit(0); # currently running process&lt;BR /&gt;  }&lt;BR /&gt;else&lt;BR /&gt;  { # process dead even though file exists&lt;BR /&gt;# unlink the original file&lt;BR /&gt;# create new PID file and write current PID&lt;BR /&gt;# do your thing&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;# remove PID file&lt;BR /&gt;   exit($status);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;I would also add signal handlers to remove this file.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Apr 2004 11:12:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257831#M714884</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-04-23T11:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257832#M714885</link>
      <description>since there is NO WAY to return to the script after an exit, I do not understand why people write&lt;BR /&gt;&lt;BR /&gt;if (expression) {&lt;BR /&gt;exit $status;&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;some other code ...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;this is IMHO cargo cult programming and only blurs the script. Just like&lt;BR /&gt;&lt;BR /&gt;cat file | process&lt;BR /&gt;&lt;BR /&gt;is unneccesarily taking system resources where&lt;BR /&gt;&lt;BR /&gt;process &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;would do just as good.&lt;BR /&gt;&lt;BR /&gt;expression and exit $status;&lt;BR /&gt;&lt;BR /&gt;and go on with the real work&lt;BR /&gt;&lt;BR /&gt;Clay, I realy enjoy your good answers, they are mostly short clear and to the point, but I just couldn't let this one go. sorry.&lt;BR /&gt;&lt;BR /&gt;BTW I think that CPAN offers a nice bunch of Unix interaction moduls and functions on  &lt;A href="ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/Proc/" target="_blank"&gt;ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/Proc/&lt;/A&gt; (Proc::ProcessTable is included in my builds), and there is even a complete HP-UX namespace: &lt;A href="ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/HPUX/" target="_blank"&gt;ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/HPUX/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 23 Apr 2004 13:54:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help/m-p/3257832#M714885</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-04-23T13:54:45Z</dc:date>
    </item>
  </channel>
</rss>

