Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STDIN and PHP vs. Perl

Status
Not open for further replies.

inlandpac

Programmer
Jun 18, 2000
235
US
Okay, here is a serious problem.<br><br>I can write a perl script that will store STDIN to a file, but when I try to use PHP to do it, it fails (no error, or anything, but just does not put anything into the file).<br><br>Example:<br>####################################<br>IN PERL -<br>#!/usr/bin/perl<br><br>print &quot;Content-type: text/html\n\n&quot;;<br>open(FILEHANDLE,&quot;&gt;/path/to/my/file/to/write/file.txt&quot;);<br><br>while(&lt;STDIN&gt;)<br>{<br>$_ = &lt;STDIN&gt;;<br>print FILEHANDLE $_;<br>}<br>close(FILEHANDLE);<br>####################################<br><br>IN PHP (supposedly) -<br>&lt;?<br>//STDIN used to be &quot;/dev/stdin&quot; but it has been changed<br>//in the newer releases of PHP<br><br>$stdin = fopen(&quot;php://stdin&quot;,&quot;r&quot;);<br>$stuff = fread($stdin,filesize($stdin));<br>fclose($stdin);<br><br>$filename = &quot;/path/to/my/file/to/write/file.txt&quot;;<br><br>$stdout = fopen($filename,&quot;w&quot;);<br>$finish = fwrite($stuff);<br>fclose($stdout);<br>?&gt;<br>####################################<br><br>Anyone know why the Perl version worked, but the PHP version did not?<br><br>Sincerely,<br>Chad.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top