cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
Hello All, I am having a bit of trouble trying to get desired result into a variable in perl script. I am doing api monitoring through zabbix via a script, and the endpoint returns {"messageType":"SUCCESS","message":"It's alive!"} .My scripts searches for the word SUCCESS and sends appropriate result, if not then zabbix sends errors. I want to put my curl command into a variable within my perl script, but all the ways I have tried do not work, maybe a different approach is needed, please assist. I have tried, but none work, error : Use of uninitialized value $4 in concatenation (.) or string at :
$status=`curl -s https://www.url/service/status| awk -F '"' '$0=$4' `; open(PS, "curl -s https://www.url/service/status| awk -F '"' '$0=$4'" +|) || die ("Failed: $!"); system qq{curl -s https://www.url/service/status| awk -F '"' '$0=$4'};
If I run the command at the command line , I get the desired result which is just the word SUCCESS
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variablize command in perl script
by hippo (Archbishop) on Aug 03, 2017 at 21:53 UTC | |
by cbtshare (Monk) on Aug 04, 2017 at 03:02 UTC | |
|
Re: variablize command in perl script
by karlgoethebier (Abbot) on Aug 04, 2017 at 08:53 UTC | |
|
Re: variablize command in perl script
by Anonymous Monk on Aug 04, 2017 at 01:50 UTC | |
by cbtshare (Monk) on Aug 04, 2017 at 03:00 UTC | |
|
Re: variablize command in perl script
by Anonymous Monk on Aug 04, 2017 at 01:39 UTC | |
by cbtshare (Monk) on Aug 04, 2017 at 02:58 UTC |