invoking exe from perl cgi

How do i invoke an exe from a perl cgi?

I tried using system(). But, i wasn't able to see any output on the browser. However when i executed the same perl script from dos prompt, it worked well.
sajithsajithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GnissmanCommented:
Put the command in backticks and you can get the result stored in a variable:

$result = `myprog.exe`;

Gniss
0
sajithsajithAuthor Commented:
I tried it. It still didn't work as a cgi. However, it works as a standalone application......when i run it from the dos prompt.

When i executed it as a cgi, i got a message stating - "Document contained no data".

The webserver (Netscape Enterprise Server) is on windows.
0
GnissmanCommented:
Could you post  the complete code of your cgi or is it too big?
This could really help a lot in finding out what the problem is.

Gniss
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

sajithsajithAuthor Commented:
The cgi program is as follows:

#!c:\perl\bin\perl
print "Content-type: text/html\n\n";
$result = `http://localhost:8000/cgi-bin/demo.exe`;
print $result;

In the above script, 'demo.exe' was placed in the CGI directory of the web server. (I have also tried placing the exe in the document directory of the web server.... and modifying '$result' appropriately).

The exe was generated from a simple c++ program which contains only a 'cout' statement.


Sajith.
0
GnissmanCommented:
Try not calling it as http://... but with it's filesystem path:

$result = `c:\\demo.exe`;

Gniss
0
sajithsajithAuthor Commented:
I tried that way. It doesn't work. I get a message stating - "document contained no data".

Sajith.
0
GnissmanCommented:
What result does this get on your machine?

#!c:\perl\bin\perl
print "Content-Type: text/html\n\n";
$result = `c:\\perl\\bin\\perl -v`;
print <<END;
<html>
  <body>
Perl Version:<br>
$result
  </body>
</html>
END
0
sajithsajithAuthor Commented:
I got the following result:

Perl Version:
Win32 port Copyright (c) 1995-1996 Microsoft Corporation. All rights reserved. Developed by ActiveWare Internet Corp.,
http://www.ActiveWare.com Perl for Win32 Build 316 - Built 09:44:44 Mar 13 1998 This is perl, version 5.003_07 Copyright
1987-1996, Larry Wall + suidperl security patch Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
0
GnissmanCommented:
So it works!
The script returned the output of "perl -v" to your browser!

Now the problem can only be
 - either in your .exe itself
 - or in the path you specified in your script.

Remember to double the \ in your path, so write
C:\\path\\folder\\file.exe instead of
C:\path\folder\file.exe

Gniss
0
sajithsajithAuthor Commented:
It worked!!!

Thank you Gniss.

Sajith.
0
GnissmanCommented:
Happy to hear!
;-)

Gniss
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.