How to use exec to execute external compile C++ program

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
mhant
Forum Newbie
Posts: 1
Joined: Sun Aug 24, 2008 2:54 am

How to use exec to execute external compile C++ program

Post by mhant »

I hope someone can help me. I am a C++ programmer and I created a program to run on a client's server and all I need is to run this program and it will create a pre-formated .html file for the client. I am trying to use the exec() command in php to run the program. Here is the code I have but can not seem to get it to work, any help would be much appreciated. All I want the code to do is run the extrenal program on my virtual server (for testing and then on the actual server)

<html>
<body>
<?php
//program is in same directory as .php file
exec('./logger.3')
?>
</body>
</html>
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: How to use exec to execute external compile C++ program

Post by marcth »

What happens when you run "logger.3" from the command line?

What does this output?

Code: Select all

 
print exec('logger.3', $output, $returnValue) ? 'Success: ' : 'Failure: ';
 
print '*' . $returnValue . '*');
print '<pre>';
print_r($output);
print '</pre>';
 
Is it possible there are permission problems preventing PHP from executing the code? Are you running Unix/Linux or Windows?
Post Reply