Answer the question
In order to leave comments, you need to log in
How to extract a number from the response to write a plugin?
I want to write a plugin for getting status codes (200, 404, etc.)
To do this, I have this line that works)))
curl -I http://www.google.com | grep HTTP; (для гугла например)
#!/bin/bash/
otvet=curl -I http://www.google.com | grep HTTP;
case $otvet in
[200]*)
echo "OK"
exit 0
;;
[404]*)
echo "Not Found"
exit 2
;;
*)
echo "UNKNOWN"
exit 3
;;
esac
[[email protected] plugins]# curl -I http://www.google.com | grep HTTP;
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
HTTP/1.1 200 OK
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question