escaping quote in exec

Issue #673 new
Former user created an issue

Hi, I need to run the following service check with monitoring

check host ERP_APACHE with address XX.XX.XX.XX
    if failed port 80   for 2 cycle then exec "/usr/bin/wget -q 'http://yy.yy.yy.yy/?page=xavoc_ispmanager_devicedown&failed_device_id=8' "

this single quote is not taken in account when running and monitoring log shows

'ERP_APACHE' exec: '/usr/bin/wget -q http://yy.yy.yy.yy/?page=xavoc_ispmanager_devicedown&failed_device_id=11'

here no quote is used and thus wget leads parameters to be send.

Question is, wget does not takes parameter in account if not in quoted like /usr/bin/wget -q "http://yy.yy.yy.yy/?page=xavoc_ispmanager_devicedown&failed_device_id=8"

but exec it self is contains in double quote ...

Thank you

Comments (3)

  1. Tildeslash repo owner

    Monit uses system/libc execv() API to execute the program and the whole quoted url is passed as single argument and it should work the way you expect.

    The program arguments are internally unquoted and stored in arguments array, the quotes are significant just when parsing the arguments: quoted string is processed as one argument.

    When monit logs the executed program, the quotes may be omitted in the output so it may look different then in your configuration file, but it is executed correctly.

    The question is, does the "exec" work as expected (wget fetched the URL)?

  2. Log in to comment