Connecting Tech Pros Worldwide Help | Site Map

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

jmuria@ole.com
Guest
 
Posts: n/a
#1: Aug 23 '07
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.

Jan =?UTF-8?B?VGhvbcOk?=
Guest
 
Posts: n/a
#2: Aug 23 '07

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


jmuria@ole.com wrote:
Quote:
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
Jerry Stuckle
Guest
 
Posts: n/a
#3: Aug 23 '07

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


jmuria@ole.com wrote:
Quote:
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
==================
jmuria@ole.com
Guest
 
Posts: n/a
#4: Aug 24 '07

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



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)


Jerry Stuckle
Guest
 
Posts: n/a
#5: Aug 24 '07

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


jmuria@ole.com wrote:
Quote:
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
==================
Jerry Stuckle
Guest
 
Posts: n/a
#6: Aug 24 '07

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


jmuria@ole.com wrote:
Quote:
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
==================
Closed Thread