[prev in list] [next in list] [prev in thread] [next in thread] 

List:       curl-and-php
Subject:    please help, cURL to retrieve e-gold exchage rate
From:       "Teguh Handoko" <hndko_th () solonet-online ! net>
Date:       2002-09-25 16:25:12
[Download RAW message or body]

Please help me with some problem as follows.

I run cURL from MSDOS prompt and run:
C:> curl http://www.e-gold.com/unsecure/metaldata.asp?latest=1

it works, it outputs something like:
9/21/02 11:30 AM,  320.00,   4.324,    540.34,    321.98

But when I run from cURL from PHP (code as follows):
<php
$curlargs = "http://www.e-gold.com/unsecure/metaldata.asp?latest=1" ;
$safecurlargs = escapeshellcmd($curlargs);
exec("\curl\curl -s $safecurlargs",$output);
while (list($indeks,$res)=each($output))
 print("Indeks: $indeks,  $res <BR>\n");
?>

Array $output does NOT contain any of the expected result of rate, but it outputs
something like:

Indeks: 0,  
Indeks: 1,  
Indeks: 2,  
Indeks: 3,  
Indeks: 4,  
Indeks: 5,  
Indeks: 6,  
Indeks: 7,  

Indeks: 8,  
Not Found  
Indeks: 9,  


Indeks: 10,  
The location you tried 
Indeks: 11,  to access is not a valid one. (Possibly our new web layout has changed a file name that 
Indeks: 12,  you might have bookmarked). If you believe this is in error please contact 
Indeks: 13,  the Gold & Silver Reserve. 




What should be the correct code ?
Thanks

Regards
Gogo










[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.100" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>Please help me with some problem as 
follows.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I run cURL from MSDOS prompt and run:</FONT></DIV>
<DIV><FONT face=Arial size=2>C:&gt; curl <A 
href="http://www.e-gold.com/unsecure/metaldata.asp?latest=1">http://www.e-gold.com/unsecure/metaldata.asp?latest=1</A></FONT></DIV>
 <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>it works, it outputs something like:</FONT></DIV>
<DIV><FONT face=Arial size=2>9/21/02 11:30 AM,&nbsp; 320.00,&nbsp;&nbsp; 
4.324,&nbsp;&nbsp;&nbsp; 540.34,&nbsp;&nbsp;&nbsp; 321.98</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>But when I run from cURL from PHP (code as 
follows):</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;php</FONT></DIV>
<DIV><FONT face=Arial size=2>$curlargs = "<A 
href="http://www.e-gold.com/unsecure/metaldata.asp?latest=1">http://www.e-gold.com/unsecure/metaldata.asp?latest=1</A>" \
 ;<BR>$safecurlargs = escapeshellcmd($curlargs);<BR>exec("\curl\curl -s 
$safecurlargs",$output);</FONT></DIV>
<DIV><FONT face=Arial size=2>while 
(list($indeks,$res)=each($output))<BR>&nbsp;print("Indeks: $indeks,&nbsp; $res 
&lt;BR&gt;\n");<BR>?&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Array $output does NOT contain any of the expected 
result of rate, but it outputs</FONT></DIV>
<DIV><FONT face=Arial size=2>something like:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Indeks: 0,&nbsp; <BR>Indeks: 1,&nbsp; <BR>Indeks: 
2,&nbsp; <BR>Indeks: 3,&nbsp; <BR>Indeks: 4,&nbsp; <BR>Indeks: 5,&nbsp; 
<BR>Indeks: 6,&nbsp; <BR>Indeks: 7,&nbsp; </DIV>
<DIV>
<DIV align=center><BR>Indeks: 8,&nbsp; 
<P><FONT face="Arial, Helvetica, sans-serif" size=3><FONT size=5><B>Not 
Found</B></FONT> <IMG height=45 hspace=10 src="http://127.0.0.1/gif/logo.gif" 
width=105 align=absMiddle></FONT> <BR>Indeks: 9,&nbsp; </P><BR>Indeks: 10,&nbsp; 

<P align=left><FONT face="Arial, Helvetica, sans-serif">The location you tried 
<BR>Indeks: 11,&nbsp; to access is not a valid one. (Possibly our new web layout 
has changed a file name that <BR>Indeks: 12,&nbsp; you might have bookmarked). 
If you believe this is in error please contact <BR>Indeks: 13,&nbsp; the <A 
href="http://127.0.0.1/unsecure/pgpkey.htm">Gold &amp; Silver 
Reserve</A>.</FONT> </P><BR></DIV>
<DIV align=center>&nbsp;</DIV></FONT></DIV>
<DIV><FONT face=Arial size=2>What should be the correct code ?</FONT></DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Regards</FONT></DIV>
<DIV><FONT face=Arial size=2>Gogo</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;</DIV></FONT>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></FONT></DIV></BODY></HTML>


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic