Ad Widget

Collapse

Running a CGI command as action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nyffex
    Junior Member
    • Jan 2023
    • 2

    #1

    Running a CGI command as action

    Hello, I´m new to Zabbix and trying to create a CGI command as action to a ICMP fail trigger.

    I´ve configured the action and it works, but I get an error on the Script I´m trying to run for the CGI command;


    Click image for larger version

Name:	image.png
Views:	208
Size:	8.3 KB
ID:	457191


    the error I get is: sh: 1: Syntax error: "(" unexpected

    I´m running Zabbix 6.0.12.

    Could someone help me spot my mistake here ?

    TIA,

    Matias
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    https://en.wikipedia.org/wiki/Shebang_(Unix)

    Linux shells (the interactive command interpreter) and UNIX shells before them don't use a registry or file extensions to determine what language interpreter should be used to execute the script. Instead, the first line in the file has a comment in a special format, that starts '#' (pronounced as "sharp") and '!' (pronounced as "bang") followed by an optional space and the interpreter to use. So:

    Code:
    #! /usr/bin/perl -w
    as the start of a script specifies to use the /usr/bin/perl interpreter to run the script and pass perl the '-w' option.

    Your script doesn't have any shbang line, so it's getting the default shell, /bin/sh or /usr/bin/sh, the Bourne shell. That's the "sh" in the error message, the "1" is line 1 of the file, the rest is self-explanatory.

    To fix your issue, add a shbang line as the first line in your script, with the path to whatever language interpreter your script needs. Make sure the file is executable too.

    Comment

    Working...