Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Calling an API from BASH script

I would like to call an API from a BASH script.
When I can call an API for first two links it works but I don’t get the same result for the two last ones (they work in a browser)

echo "Kuma null"
curl --silent https://status.lol.net/api/push/UGUH?msg=OK > /dev/null
sleep 5
echo "Kuma not null"
curl --silent https://status.lol.net/api/push/UGUH?msg=OK
sleep 5
echo "Pi-hole null"
curl --silent http://192.168.0.22:5555/admin/api.php?disable=600&auth=54 > /dev/null
sleep 5
echo "Pi-hole not null"
curl --silent http://192.168.0.22:5555/admin/api.php?disable=600&auth=54
sleep 5

Output:

Kuma null
Kuma not null
{"ok":true}Pi-hole null
[]Pi-hole not null
[]

What do I need to change?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

curl --silent http://192.168.0.22:5555/admin/api.php?disable=600&auth=54

You need to quote the URL like this:

curl --silent "http://192.168.0.22:5555/admin/api.php?disable=600&auth=54"

Otherwise it’ll be interpreted as

curl --silent http://192.168.0.22:5555/admin/api.php?disable=600 & auth=54
#                                                               ^^^^^^^^^^
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading