1-please tell me if i am not clear, or i if am otherwise frustrating as i ask questions - i do not want to bite the hand that feeds me! 2-i have perl code to run a remote command like this focus on $remoteCmd:
#!/usr/bin/perl -w use Net::SSH::Perl; use Net::SSH::Expect; my $remoteCmd = `ssh myserverid.company.com -l myuid -i /home/myuid/.s +sh/authorized_keys top`;
As you can see, i try to start "top" - which errs with "TERM environment variable not set." - but even if i were able to start a service using the $remoteCmd = `ssh... cmd, whatever service i start, i need to capture the pid # of the service i just started. i tried your code like this, which did produce a temporary pid:
#!/usr/bin/perl -w use IO::Handle; my $handle = IO::Handle->new; my $pid = open($handle, 'command & |') or die $!; print $pid;
... and that pid prints; so whatever that did, it produced a pid; but i want is to start my own service or process, then capture that pid. then i will check the process table to see if the pid name, and pid # exist. if so, the process is running. if not, i need to restart it. i hope i am clear. basically, i need to ssh to a remote server, start a process, then capture the pid # back to the local perl script that calls the ssh. any ideas? can you help? again, if i am not clear, i will retool my presentation again and strive for even more clarity. thanks!

In reply to Re: Launch process, get PID by dcparham
in thread Launch process, get PID by rvosa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.