M
M
Maxi-II2017-09-12 16:06:58
linux
Maxi-II, 2017-09-12 16:06:58

How to pass the result of cURL execution to a PHP script on the Linux command line?

Hello,
I need to pass the result of executing an external script (first.php) to another PHP script (second.php).
All this must be done through the Linux command line.
I try like this, but it doesn't work:
/usr/bin/curl - o 2>&1 /dev/null " sitename.ru/first.php " | /usr/bin/php /var/www/second.php
In second.php I look at the $argv array
Help please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-09-12
@Maxi-II

pipe passes data not to arguments but to stdin. You must either look at the contents of stdin in php, or write the bash command differently in order to pass the result of the previous command as an argument. In my opinion xargs allows you to do this.
Or you can rewrite the script differently -
whatever is in the parentheses will be executed first and stdin will be passed as an argument.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question