How would I execute a PHP command?

Just starting out? Need help? Post your questions and find answers here.
roachofdeath
User
User
Posts: 78
Joined: Sun Apr 24, 2005 3:22 am

How would I execute a PHP command?

Post by roachofdeath »

I am trying to think about ways to execute a PHP file or command silently. Any suggestions?
Jellybean
User
User
Posts: 95
Joined: Wed Aug 24, 2005 7:33 pm

Post by Jellybean »

Code: Select all

RunProgram("php.exe", "filename", "c:\diroffilename\", 1|2)
?
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

You need to download php or ActivePhp to be able to run it in your computer.

if you are looking for PHP string commands only, as far as i can remember there is some lib on purearea.net about that, but is not running php, for real php only have php installed on your PC.
ARGENTINA WORLD CHAMPION
Jellybean
User
User
Posts: 95
Joined: Wed Aug 24, 2005 7:33 pm

Post by Jellybean »

I think (at least I hope) he knows that he needs to have php installed. :? :lol:
roachofdeath
User
User
Posts: 78
Joined: Sun Apr 24, 2005 3:22 am

Post by roachofdeath »

im not reatarded, and I know PHP

here is what im talking about...

for example if i somehow tell purebasic to execute:

Code: Select all

<?PHP
$f=fopen("whatever.txt","w");
echo fwrite($f,"C:\TestFile.txt");
fclose($f);
?>
then i wish for it to execute the code, and create the .txt file. I don't want to do that exactly, but that's what I mean
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

If you have PHP installed, if your webserver are properly configurated and if this PHP code its okay, should work fine.

One question: you need to do it in PHP?
I mean, if you are using a PB coded webbrowser, you can do the same without using PHP and will be easier and your distributable file will be smaller since dont need PHP.
ARGENTINA WORLD CHAMPION
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

roachofdeath wrote: for example if i somehow tell purebasic to execute
PB dont execute PHP.

If you have PHP installed, and configure your web server fine, when it receives a call to a .php page, it will sent it to PHP.exe on your computer and only receive the result from php.exe and send it to the client.

Its the same as a CGI, the server call the appropiate executable to interpret the code and receive the response (code already interpreted) from .exe
ARGENTINA WORLD CHAMPION
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

You could execute your example code snippet

Test.php

Code: Select all

<?PHP
$f=fopen("whatever.txt","w");
echo fwrite($f,"C:\TestFile.txt");
fclose($f);
?>
by using PB-Runcommand even without running a webserver. Just try
to execute the php.exe like this :

Code: Select all

[pathTOphp]/php.exe -q -f Test.php
That would execute above's PHP-Code.

To get the output (i.e. the result of fwrite) you could use the
following:

Code: Select all

php.exe -q -f Test.php > Test.html

Test.html now stores the output of the "echo fwrite()" command.


Maybe this info is of some help for you :?: :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
pantsonhead
User
User
Posts: 39
Joined: Fri Mar 26, 2004 1:47 pm
Location: London, UK
Contact:

Post by pantsonhead »

hey roach,

I assume you are calling php from commandline (not in a browser).
Not many folks use php this way but it's great. I converted a bunch of VB file/mail processing applications to php and they run about 8 times faster.

If you aren't using commandline php then do it, and refer to Jellybean's post above.

EDIT : looks like Benny types faster than me
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

The problem will be that is building static pages and if you have multiple clients could have problems.

Calling from iniside PB server, like a CGI makes it handle just like any other server: dynamic content.
ARGENTINA WORLD CHAMPION
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

well in fact things could be done anyway if he has a queue list, then he'll be able to process every "client" and have the other awaiting till that one is done, then the next one, on the barber shop to get that fancy new cut he wanted! - Depends on what hes going to programm though.

I guess that now hes able to do what he wanted - why speculating?
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
roachofdeath
User
User
Posts: 78
Joined: Sun Apr 24, 2005 3:22 am

Post by roachofdeath »

benny, that seems about what I wanted to do in the first place, but I was unsucsessful finding the php exe. Whenever I try to run a PHP file, it just has me download it :|
User avatar
griz
Enthusiast
Enthusiast
Posts: 167
Joined: Sun Jun 29, 2003 7:32 pm
Location: Canada

Post by griz »

Roach, have you checked out my 'php brew' code here on the forums?

viewtopic.php?t=13982&highlight=

Does this help?
Post Reply