PB and PHP : Help needed please !

Everything else that doesn't fall into one of the other PB categories.
delta69
User
User
Posts: 15
Joined: Fri Apr 25, 2003 10:56 pm

PB and PHP : Help needed please !

Post 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) :

Code: Select all

<?php 
passthru("console.exe");
?>
... 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 )
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Try this

Code: Select all

 If OpenConsole() 
  PrintN("Hello world !") 
  Input()
  CloseConsole()
EndIf 
End 
delta69
User
User
Posts: 15
Joined: Fri Apr 25, 2003 10:56 pm

Post by delta69 »

Thanks for your help Droopy, but unfortunately, it doesn't work better... :-(

Regards,
Nicolas
Fred
Administrator
Administrator
Posts: 18161
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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>&nbsp;</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
Last edited by Beach on Wed May 04, 2005 8:06 pm, edited 1 time in total.
-Beach
delta69
User
User
Posts: 15
Joined: Fri Apr 25, 2003 10:56 pm

Post 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
Fred
Administrator
Administrator
Posts: 18161
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The CGI lib way is a good way as it actually uses the printf() like commands
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

These functions should be implented in PureBasic.
Fred
Administrator
Administrator
Posts: 18161
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

yes, that's what i said just above.
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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.
-Beach
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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 :)
Image Image
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

:? Is there a linux version of the CGI lib?
bye,
Daniel
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Sorry, don't use Linux here. ;)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Ok, this sounds stupid... i know many things, but i haven't yet understood who in hell this CGI stuff works! :oops:

Can anyone shed some light?
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post 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.
bye,
Daniel
Post Reply