Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 23rd, 2007, 04:05 PM
jmuria@ole.com
Guest
 
Posts: n/a
Default Using exec function to get a .exe return status gives CGI Error

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.


  #2  
Old August 23rd, 2007, 04:45 PM
Jan =?UTF-8?B?VGhvbcOk?=
Guest
 
Posts: n/a
Default 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
  #3  
Old August 23rd, 2007, 05:05 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================
  #4  
Old August 24th, 2007, 07:55 AM
jmuria@ole.com
Guest
 
Posts: n/a
Default 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)


  #5  
Old August 24th, 2007, 11:35 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================
  #6  
Old August 24th, 2007, 04:55 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.