Solved

Using command line

Posted on 2004-05-01
3
272 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

770 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