Page 1 of 2
PB and PHP : Help needed please !
Posted: Wed May 04, 2005 6:37 pm
by delta69
Hello,
I'm trying to run an executable file made with PureBasic through PHP, but it does not work as it should. The result of the PB program should be displayed on a web page using PHP's passthru() function.
I built a very simple PB EXE (named console.exe, in my example, compiled as a console app) :
Code: Select all
If OpenConsole()
PrintN("Hello world !")
CloseConsole()
EndIf
End
... and then the PHP file (index.php) :
... But nothing happens... I just have a blank web page displayed. If I replace the console.exe file by hostname.exe (provided by MS in WinXP system32 directory), then it works fine.
I don't know what is wrong with my PB code, because both of the EXE files seems to react the same way when launched in a MS-DOS box... Any idea ? Thanks for your help !
Regards,
Nicolas
( Win XP Pro SP2 / PB 3.93 / EasyPHP 1.8 )
Posted: Wed May 04, 2005 7:08 pm
by Droopy
Try this
Code: Select all
If OpenConsole()
PrintN("Hello world !")
Input()
CloseConsole()
EndIf
End
Posted: Wed May 04, 2005 7:31 pm
by delta69
Thanks for your help Droopy, but unfortunately, it doesn't work better...
Regards,
Nicolas
Posted: Wed May 04, 2005 7:44 pm
by Fred
The PB commands for console uses the graphic mode which isn't suitable for php and other regular stdin software. You will have to find a wrapper around puts_() or printf_() to achieve what you want. We plan to add this feature to the console lib soon.
Posted: Wed May 04, 2005 8:03 pm
by Beach
I would use Paul's CGI lib to output the text. Just like all of Paul's stuff, it is very easy to use. I compiled the following code and put the resulting exe in a folder off my IIS root folder, then I changed the execute permissions for the new folder to "Scripts and Executeables".
Code: Select all
CGI_In()
Text$ = CGI_Val("pbtext")
CGI_Header()
CGI_Out("<p> </p>")
CGI_Out("<center>Your text was: ")
CGI_Out(Text$)
Now just call the file with parameters in a link or on a form, just remember to use the "Get" method instead of "Post" if you use a form. Example: "
http://localhost/cgi-bin/cgitest.exe?pbtext=Testing"
[Edit] wrong link...
http://www.reelmedia.org/cgi-bin/PurePr ... es&sub=ASM
Posted: Wed May 04, 2005 8:03 pm
by delta69
Thanks for your reply, Fred.
Due to my PB skills, I think I will wait for the command to be included in the next release
I just saw that Beach gave a tip, using a different method... I will have a try right now...
Regards,
Nicolas
Posted: Wed May 04, 2005 8:08 pm
by Fred
The CGI lib way is a good way as it actually uses the printf() like commands
Posted: Wed May 04, 2005 8:13 pm
by Bonne_den_kule
These functions should be implented in PureBasic.
Posted: Wed May 04, 2005 8:16 pm
by Fred
yes, that's what i said just above.
Posted: Wed May 04, 2005 8:19 pm
by Beach
Fred wrote:We plan to add this feature to the console lib soon.
Thanks Fred, that will really help out on a few of the projects I have going on at the moment.
Posted: Wed May 04, 2005 10:35 pm
by Paul
Yes, the CGI Lib on
http://www.pureproject.net is really cool and quite easy to use:
CGI_In() for data input
CGI_Out() for data output
You can even include complete html pages in your EXE and then output them using the command CGI_MemOut()
It will also allow you to enable uploads to your server... CGI_FileIn()
PureProject.net runs completely from a single CGI built with this library

Posted: Thu May 05, 2005 1:21 pm
by DarkDragon

Is there a linux version of the CGI lib?
Posted: Thu May 05, 2005 3:36 pm
by Paul
Sorry, don't use Linux here.

Posted: Thu May 05, 2005 7:03 pm
by Num3
Ok, this sounds stupid... i know many things, but i haven't yet understood who in hell this CGI stuff works!
Can anyone shed some light?
Posted: Fri May 06, 2005 7:22 am
by DarkDragon
Paul wrote:Sorry, don't use Linux here.

Yes, but it would be nice because very less ppl have windowsservers O_o. Linux Servers are used by the hosters.