Search code examples
phppopen

Php popen only returns bool(true) instead of a pointer


I'm wondering that my simple popen() call only returns the boolean value TRUE instead of a resource.

Therefore the following fputs() throws a warnings like "Warning: fputs() expects parameter 1 to be resource, boolean given [...]"

As described in the Php manual, I expect a resource/pointer or FALSE in return.

Here is my example:

$path = 'C:\path\to\oracle\product\11.2.0\server\bin\sqlplus.exe';
$ph = popen($path,'w') || die ("Program not found");
fputs($ph, "username/password"\n");

Can anybody help?!


Solution

  • Change :

    $ph = popen($path,'w') || die ("Program not found"); to $ph = popen($path,'w');

    remove everything after || and try.

    Also there is extra quote here : fputs($ph, "username/password"\n"); remove one fputs($ph, "username/password\n");