Respected Monks,

I am trying to execute few commands by using the pipe from open function and pushing the required information into files and reading the same data.

open (CONS,"| SSM/bin/ssmcons $ip > ./logs/ssm/$ip 2>&1") or +die "Could not open: $!"; print CONS "$password \n"; print CONS "subagent list\n"; print CONS "quit\n"; close (CONS);
The first command after execution opens a new command prompt , for which we provide a password for authentication and then give the required command "subagent list" to get some health information and quit the command prompt. Its gives the perfect output when the password specified to it is correct. All the information is pushed into the files.

But when we execute the same commands on the command prompt by giving an incorrect password, it retries for three times and prints a message
"Aborted Negotiation"

But when trying the same in-correct password scenario using the open pipe function. In the result file we can only see the "Incorrect password" trying for three times and not giving out the below expected message.
"Aborted Negotiation"

And inturn when checked for the process status using the ps command I could see that the incorrect password process is running continously and even its consuming more CPU usage around ( 50% ) by monitoring the CPU usage.

> ps -ef | grep ssmcons nobody 2441 2440 50 15:25:45 ? 63:00 ../../htdocs/bin/ssmcon +s.bin ip_address nobody 2440 1 0 15:25:45 ? 0:00 sh -c ../../htdocs/bin/ +ssmcons ip_address > ./logs/ssm/ip_address PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLW +P 2441 nobody 5224K 3048K cpu0 20 0 1:04:40 50% ssmcons.bin +/1
And the main concern is that in case of incorrect password scenario, the above process is running continously and also consuming excess CPU usage. Any suggestion regarding the above would be of great help.

Thanks in Advance.


Sushil Kumar

In reply to Command execution through pipe from Open function by msk_0984

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.