2

I have been trying to run this PHP script. There is no output whatsoever and I cannot seem to understand the reason.

<?php

echo "Example DOI Query <be>";

$doi = someDOIvalue;

echo 'DOI: '.$doi.'<br>';

$query = 'curl -LH "Accept: application/json" http://doi.org/';

$cmd = $query.$doi." | jq '.title'";

echo $cmd;

$title = shell_exec($cmd);

echo 'Title:<br>'.$title;

?>

However, when I try to use the same command on my LINUX command line (as below), it works perfectly fine.

curl -LH "Accept: application/json" http://doi.org/10.1016/someDOIvalue | jq '.title' 

Any idea what I'm doing wrong?

6
  • I would check your webserver logs, PHP probably doesn't have permission to run an exec or something like that. Is this CentOS? Commented Apr 9, 2022 at 15:30
  • Also try calling jq from its absolute path like /usr/bin/jq. Commented Apr 9, 2022 at 15:34
  • No, using Debian Linux. Commented Apr 9, 2022 at 15:37
  • tried the absolute path too. It didn't work for me! Commented Apr 9, 2022 at 15:44
  • 1
    @Nigel thanks! It worked. Turns out I need to give full path names for both jq and curl Commented Apr 9, 2022 at 17:15

1 Answer 1

-2

there are a lot of reasons for this issue try to check

the group and the permission also use the full path of the command

I hope it's help full

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.