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!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.