bilbo-uk
asked on
parsing external cgi script results to variable in PHP
I want to put the reult of a CGI script into a string, then into an array so i can reformat the results.
I am able to call the external CGI script, which returns the correct result but cant figure out how to get the reults into a string.
The external CGI script is:
http://checker.cerberusnetworks.co.uk/cgi-bin/externaldslcheck.cgi?pstn=01279466222&user=csuk&pass=druney73
The value that is returned is:
ADSL2PLUS_ANNEXA_UP_ESTIMA TE=1.25 ADSL2PLUS_ANNEXA_DOWN_ESTI MATE=14.18 1 ADSL2PLUS_STATUS=0 BT_LINE_LENGTH=1904
does anybody know how to do this?
I am able to call the external CGI script, which returns the correct result but cant figure out how to get the reults into a string.
The external CGI script is:
http://checker.cerberusnetworks.co.uk/cgi-bin/externaldslcheck.cgi?pstn=01279466222&user=csuk&pass=druney73
The value that is returned is:
ADSL2PLUS_ANNEXA_UP_ESTIMA
does anybody know how to do this?
<?php
$pstn2 = $_POST["pstn"];
echo "$pstn2";
echo "<br /><br />";
$str = include("http://checker.cerberusnetworks.co.uk/cgi-bin/externaldslcheck.cgi?pstn=01279466222&user=csuk&pass=druney73");
echo "<br /><br />";
echo $str;
echo "<br /><br />";
echo $str;
echo "<br /><br />";
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry but the person who posted this has now left the company hence why a comment has not been left earlier. I don't think it was a complete solution but gave him some things to try which lead to working out how to do it.
If I can find where the code is I will post what he ended up going with
Thanks
If I can find where the code is I will post what he ended up going with
Thanks
ASKER
In the end this was done as follows by the look of things
$str = file_get_contents("http://checker.cerberusnetworks.co.uk/cgi-bin/externaldslcheck.cgi?pstn=$pstn2&user=&pass=");
$a = explode(" ", $str);
Then access those array variables
$length = "$a[3]";
$down = "$a[1]";
$status = "$a[2]";
$up = "$a[0]";
Regards
Paul
$str = file_get_contents("http://checker.cerberusnetworks.co.uk/cgi-bin/externaldslcheck.cgi?pstn=$pstn2&user=&pass=");
$a = explode(" ", $str);
Then access those array variables
$length = "$a[3]";
$down = "$a[1]";
$status = "$a[2]";
$up = "$a[0]";
Regards
Paul
print_r($arr);