Using exec function to get a .exe return status gives CGI Error

Using exec function to get a .exe return status gives CGI Error

am 23.08.2007 17:57:58 von jmuria

Hi.

I'm trying to make a web page to work. It worked before so it has to
be something related with the configuration.
My problem is a call to a compiled executable (made for me) that
returns 1 or 0. It does not print any text to the standard ouput so
the error is strange:
CGI Error: The script can .. because of the HTTP headers (I have it in
spanish so the message is not the exact one).

As supposed, the HTTP headers are needed only if the executable prints
out a text to the browser but it's not the case. And (I repeat) It
worked as it before. The machine had to be formatted and the guy in
charge of that is not with me anymore.

Any help will be apreciated.

Re: Using exec function to get a .exe return status gives CGI Error

am 23.08.2007 18:43:41 von kork

jmuria@ole.com wrote:
> My problem is a call to a compiled executable (made for me) that
> returns 1 or 0. It does not print any text to the standard ouput so
> the error is strange:
> CGI Error: The script can .. because of the HTTP headers (I have it in
> spanish so the message is not the exact one).

Could you maybe post the relevant parts of your PHP script ?

Best regards,
Jan

--
____________________________________________________________ _____________
insOMnia - We never sleep...
http://www.insOMnia-hq.de

Re: Using exec function to get a .exe return status gives CGI Error

am 23.08.2007 18:58:20 von Jerry Stuckle

jmuria@ole.com wrote:
> Hi.
>
> I'm trying to make a web page to work. It worked before so it has to
> be something related with the configuration.
> My problem is a call to a compiled executable (made for me) that
> returns 1 or 0. It does not print any text to the standard ouput so
> the error is strange:
> CGI Error: The script can .. because of the HTTP headers (I have it in
> spanish so the message is not the exact one).
>
> As supposed, the HTTP headers are needed only if the executable prints
> out a text to the browser but it's not the case. And (I repeat) It
> worked as it before. The machine had to be formatted and the guy in
> charge of that is not with me anymore.
>
> Any help will be apreciated.
>

What language is it written in? If it's something like C or C++, for
instance the libraries open stdout/stderr by default. It might be
causing your problem - but I doubt it.

More likely is that you're getting an error during the execution and the
system is trying to write something to stderr (or stdout). For
instance, you might not have the correct permissions to execute the file.

Try this:

1. Log onto the command line interface (ssh/telnet)
2. su to the webserver user
3. cd to the directory you're PHP script is in
4. Enter the command just as it is in the exec() call.

What happens?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Using exec function to get a .exe return status gives CGI Error

am 24.08.2007 09:45:22 von jmuria

Thanks to both of you.

I write the PHP code

exec("myapp.exe ".$_POST["password"]." ". $cifrado[0]["PASSWORD"] ,
$output,$result);
echo $result;

if($result== 1)
{
....

The language is C++ but there is not printf or cout to generate any
text output. If I execute the command with cmd (I use Windows 2003
Server) the command is executed without problems (and no text output)

Re: Using exec function to get a .exe return status gives CGI Error

am 24.08.2007 13:30:14 von Jerry Stuckle

jmuria@ole.com wrote:
> Thanks to both of you.
>
> I write the PHP code
>
> exec("myapp.exe ".$_POST["password"]." ". $cifrado[0]["PASSWORD"] ,
> $output,$result);
> echo $result;
>
> if($result== 1)
> {
> ...
>
> The language is C++ but there is not printf or cout to generate any
> text output. If I execute the command with cmd (I use Windows 2003
> Server) the command is executed without problems (and no text output)
>
>

It may not matter that there is no output. It opens stdout/cout, which
may be enough. I'm not sure on a Windows machine.

Also, headers are ALWAYS required. The browser makes a request, the
server MUST respond with headers, even if no data is sent (otherwise the
browser will time out).

But this should not affect script execution. What's the real message
you're getting (translated, please, as best you can - I don't so Spanish).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Using exec function to get a .exe return status gives CGI Error

am 24.08.2007 18:46:20 von Jerry Stuckle

jmuria@ole.com wrote:
> Thanks to both of you.
>
> I write the PHP code
>
> exec("myapp.exe ".$_POST["password"]." ". $cifrado[0]["PASSWORD"] ,
> $output,$result);
> echo $result;
>
> if($result== 1)
> {
> ...
>
> The language is C++ but there is not printf or cout to generate any
> text output. If I execute the command with cmd (I use Windows 2003
> Server) the command is executed without problems (and no text output)
>
>

BTW - I still go back to a possible security issue. Does the webserver
user have permission to execute the C++ program?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================