user6243824 user6243824 - 6 months ago 19
Bash Question

Print response of PHP script to client terminal

I have this

.sh
one-liner script:

curl http://example.com/script.php


script.php
at the server looks like this:

echo "hello"


How can I modify the
.sh
script to catch the output of
script.php
?

Answer

How can I modify the .sh script to catch the output of script.php?

You can capture it in a variable like so:

MY_VAR=$(curl -s http://example.com/script.php)

Use -s to prevent the progress from displaying in stdout. From here you can use $MY_VAR to control the output.

Comments