Solved

Using command line

Posted on 2004-05-01
3
265 Views
Last Modified: 2008-03-06
How can I use some program like Delphi or Visual C++ to get information from php file with command line. Exam:

a.php
<?php
$a=12;
echo '<html>';
echo $a;
echo '</html>'
?>

When I run the command c:\php\php.exe c:\test\a.php , it show out the command line :

<html>
12
</html>

How can I get that information from other program.
0
Comment
Question by:AkaZn
3 Comments
 
LVL 14

Expert Comment

by:ThG
ID: 10968574
This doesn't have anything to do with PHP, but i'll reply anyway. You have to actually "run" your php script, exactly the same way when you do c:\php\php.exe c:\test\a.php.

See this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp

and this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_processes.asp
0
 
LVL 3

Accepted Solution

by:
Aliev earned 50 total points
ID: 10972245
On delphi,
shellexecute(handle,'Open',pchar('C:\PHP\php.exe'),pchar('C:\www\test.php >result.txt),'',0);


The results will be written to result.txt file but with headers. You can fix this problem by deleting some lines from file. And then open programmaticaly on delphi result.txt.




0
 

Author Comment

by:AkaZn
ID: 11007209
shellexecute(handle,'Open',pchar('C:\PHP\php.exe'),pchar('C:\www\test.php >result.txt),'',0);


I think that the >filename command can only be used in msdos or nc. I have try your function but it doesn't work. But anyway, you are right. I use that command instead:

shellexecute(handle,'Open',pchar('command'),pchar('/C 'C:\PHP\php.exe C:\www\test.php >result.txt),'',1);

It will use command (msdos) and excute php.exe.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now