LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-28-2014, 12:37 PM   #1
luftwaffe
LQ Newbie
 
Registered: Jul 2002
Posts: 19

Rep: Reputation: 0
read/write with popen in php


There are two pieces of code:
Code:
$handle = popen('php x.php', 'w');
$write = fwrite($handle, "abc\r\n");
echo $write;
sleep(10);
pclose($handle);
$write shows me that all 5 characters are written. The problem is that those are never received in the other (x.php) file:
Code:
do {
    $c = fgets(STDIN);
    print($c);
} while (!feof(STDIN));

sleep(10);
I would like to see at least an 'a' character printed by the second script but it does not show anything. Any clue why and how to get this working?
 
Old 12-28-2014, 01:33 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
1. try fflush
2. try strace -f php outer.php
 
Old 12-28-2014, 02:51 PM   #3
luftwaffe
LQ Newbie
 
Registered: Jul 2002
Posts: 19

Original Poster
Rep: Reputation: 0
Thank you for the quick reply.
1. I added fflush($handle); after the fwrite($handle, "abc\r\n); but unfortunately it does not help.
2. There is no strace as I run on windows (PHP 5.6.4 (cli) (built: Dec 17 2014 13:21:16)). - Yeah, I understand this is linux forum. Still, this should work the same, should not?

Last edited by luftwaffe; 12-28-2014 at 02:52 PM.
 
Old 12-28-2014, 03:05 PM   #4
luftwaffe
LQ Newbie
 
Registered: Jul 2002
Posts: 19

Original Poster
Rep: Reputation: 0
OMG... Now I am really clueless.
I loaded a CentOS 6 and ran the same code. Actually it works there. It just seems to be not working on Windows. Hmm...
 
Old 12-28-2014, 03:24 PM   #5
luftwaffe
LQ Newbie
 
Registered: Jul 2002
Posts: 19

Original Poster
Rep: Reputation: 0
https://bugs.php.net/bug.php?id=68668
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - Newbie 16 09-01-2010 09:07 AM
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - General 2 08-26-2010 03:32 PM
Mounting Drive Read-Write for PHP HappyDude Linux - Software 0 09-04-2004 07:19 PM
popen read and write (both) how C++Boar Programming 2 07-05-2004 01:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration