I've a php file which I've hosted on some server, now I want to access the output of URL via curl like:
curl -s http://ankur.serve.qa.vdopia.com/getTag.php?type=vanilla&tag=master
[1] 81246
**vanilla4.9.8-2**
I am getting hell lot of things but the actual output which is vanilla4.9.8-2 comes little late and as soon as I hit enter after typing curl command, it just shows me the process id and goes in back ground. How do I get the output without taking the command in background.
here is whole code of php:
header('Content-type: text/plain');
$type = $_GET['type'];
$tag = $_GET['tag'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($type=='portal')
{
if($tag=='' || $tag=='master')
{
curl_setopt($ch, CURLOPT_URL, 'http://portal.vdopia.com/version.txt?'.uniqid());
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
}
else if ($type=='vanilla')
{
if($tag=='' || $tag=='master')
{
echo 'checking';
curl_setopt($ch, CURLOPT_URL, 'http://serve.vdopia.com/version.txt?'.uniqid());
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
}
exit();
The & in your curl command sends curl (or any shell command) into the background. You need to escape & to remove this special meaning for shell. Just executing your command like this solves the problem:
curl -s 'http://ankur.serve.qa.vdopia.com/getTag.php?type=vanilla&tag=master'
Outputs:
vanilla4.9.8-21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With