<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=iso-8859-15">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>The execution in bischeck for a check command is done with a
      simple Runtime.getRuntime().exec("your command") where "your
      command" in your example is:</p>
    <p>/usr/bin/python3.5 /usr/local/nagios/libexec/script_test.py -h
      hostname -w host=myHost and par=myPar</p>
    <p>Using Runtime.getRuntime().exec just take the string and try to
      execute it without any understanding of what a normal shell would
      do with quoting, piping, env variables, etc. For the exec method
      space is the only separator. So anything like that is up to your
      program to be manage, like your workaround.</p>
    If you need to have a full shell context running your command or
    even do pipeline you can check out
<a class="moz-txt-link-freetext" href="http://codewhitesec.blogspot.se/2015/03/sh-or-getting-shell-environment-from.html">http://codewhitesec.blogspot.se/2015/03/sh-or-getting-shell-environment-from.html</a>
    to do some magic stuff in the exec() method.<br>
    <br>
    /Anders<br>
     <br>
    <div class="moz-cite-prefix">On 01/11/2018 04:24 PM, Francesco
      Giuseppe Toffoli wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:bf14a103-1297-3a05-5ce6-1327c8ba8520@skylogic.it">
      <meta http-equiv="content-type" content="text/html;
        charset=iso-8859-15">
      <p>Hi everybody,<br>
        I've the following situation. I' using a script, which is run in
        the <execstatement>.<br>
        The script gets some parameters from the CLI:<br>
      </p>
      <p><execstatement>{"check":"/usr/bin/python3.5
        /usr/local/nagios/libexec/script_test.py -h hostname <b>-w
          host=myHost and par=myPar</b> ",
        "label":"value"}</execstatement></p>
      <p>One of the CLI parameters, (-w in this example), takes a string
        separated by spaces (%s). <br>
        I've seen that Bischeck in this case does not run the
        script,raising an exception,  probably does not recognize the
        spaces.<br>
        Also surrounding the parameter with ' or escaped \" does not
        work:</p>
      <p><b>-w 'host=myHost and par=myPar'<br>
        </b><b><b>-w \"host=myHost and par=myPar\"</b></b></p>
      <p><b><b><br>
          </b></b></p>
      <p>The workaround i found is to separate the string argument with
        a comma, and inside the script split them by the comma and
        recreate the desired string.<b><b> </b></b>(host=myHost,and,par=myPar).<br>
        Is there an easier way?</p>
      <p>Thanks,<br>
        Francesco<br>
      </p>
      <p><b><b><br>
          </b></b></p>
      <p><br>
      </p>
      <p><br>
      </p>
      <div class="moz-signature">-- <br>
        <meta http-equiv="content-type" content="text/html;
          charset=iso-8859-15">
        <title></title>
        <p class="MsoNormal"><font size="-1" color="#3333ff">Francesco
            Giuseppe Toffoli</font><span
            style="font-size:10.0pt;font-family:"Times New
            Roman","serif";color:black;mso-fareast-language:IT"><br>
            Monitoring Engineer</span><span
            style="mso-fareast-language:IT"></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Times New
            Roman","serif";mso-fareast-language:IT">GSE
            Department</span><span style="mso-fareast-language:IT"></span>
        </p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Times New
            Roman","serif";mso-fareast-language:IT">Tel:
            +39 0112738748<font size="-1">8</font></span><span
            style="mso-fareast-language:IT"><o:p></o:p></span></p>
        <span style="font-size:10.0pt;font-family:"Times New
          Roman","serif";mso-fareast-language:IT">Mobile:
          +39 349.800.60.35 <span style="color:black"><br>
            Email: </span><u><span style="color:blue"><a
                href="mailto:ftoffoli@skylogic.it"
                moz-do-not-send="true">ftoffoli@skylogic.it</a></span></u></span><span
          style="font-size:12.0pt;font-family:"Times New
          Roman","serif";color:black;mso-fareast-language:IT"><br>
        </span><b><span style="font-size:12.0pt;font-family:"Times
            New
Roman","serif";color:#000099;mso-fareast-language:IT"><img
              shrinktofit="true" id="_x0000_i1025"
src="imap://aha%40ingby%2Ecom@mail.messagingengine.com:993/fetch%3EUID%3E.INBOX.Drafts%3E5859?part=&filename=/home/franz/skylogic_logo.jpeg"
              moz-do-not-send="true" height="44" border="0" width="190"><br>
          </span></b><b><span
            style="font-size:10.0pt;font-family:"Times New
            Roman","serif";color:#000099;mso-fareast-language:IT">Skylogic
            S. p. A.</span></b><span
          style="font-size:10.0pt;font-family:"Times New
          Roman","serif";color:black;mso-fareast-language:IT"><br>
          Strada Pianezza, 289<br>
          10151 Torino, Italy </span> </div>
      <br>
      This message contains confidential information and is intended
      only for the individual named. If you are not the named addressee
      you should not disseminate, distribute or copy this e-mail. Please
      notify the sender immediately by e-mail if you have received this
      e-mail by mistake and delete this e-mail from your system. E-mail
      transmission cannot be guaranteed to be secure or error-free as
      information could be intercepted, corrupted, lost, destroyed,
      arrive late or incomplete, or contain viruses. The sender
      therefore does not accept liability for any errors or omissions in
      the contents of this message, which arise as a result of e-mail
      transmission. If verification is required please request a
      hard-copy version. Please note that any views or opinions
      presented in this email are solely those of the author and do not
      necessarily represent those of the Company.<br>
      No employee or agent is authorized to conclude any binding
      agreement on behalf of this Company nor, through thi s latter, any
      of the Eutelsat Communication group with another party by email
      without express written confirmation by a duly authorized officer
      of the Company. The list of duly authorized officers and the scope
      of their powers is published on the Trade Register according to
      the national law of each affiliate.
      <br>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 


Ingby <a class="moz-txt-link-rfc2396E" href="http://www.ingby.com"><http://www.ingby.com></a>

bischeck - dynamic and adaptive monitoring for Nagios <a class="moz-txt-link-rfc2396E" href="http://www.bischeck.org"><http://www.bischeck.org></a>

<a class="moz-txt-link-abbreviated" href="mailto:anders.haal@ingby.com">anders.haal@ingby.com</a><a class="moz-txt-link-rfc2396E" href="mailto:anders.haal@ingby.com"><mailto:anders.haal@ingby.com></a>

Mjukvara genom ingenjörsmässig kreativitet och kompetens

Ingenjörsbyn
Box 531
101 30 Stockholm
Sweden
<a class="moz-txt-link-abbreviated" href="http://www.ingby.com">www.ingby.com</a> <a class="moz-txt-link-rfc2396E" href="http://www.ingby.com/"><http://www.ingby.com/></a>
Mobil: +46 70 575 35 46
Tele: +46 75 75 75 090
Fax:  +46 75 75 75 091
</pre>
  </body>
</html>