Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing perl scripts from C++

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I wrote a cgi script in Borland C++ and obviously I can compile it into an exe file but my server won't run exe files in the cgi-bin. it will only run .pl or .cgi scripts.

Does anyone know how I can convert the exe file to a .pl script? Or convert the original source code?

Thanks

fergmj
 
Your problem with running exe files may be one of a couple of things:

1. Make sure world execute privelege is set for the exe file when you upload it to the cgi-bin directory.

2. If the C++ file is compiled on a different platform or OS that the one on which your server it runnning, it simply will not work.

Unless you are doing something that particularly requires C++ it shouldn't be difficult to do the same thing in perl, but I don't know of any "conversion programs." You'll just have to take the source code and rewrite it in perl. You may even find that the program is SIMPLER in perl!
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
It would be a work around, but, you could write a Perl wrapper for your .exe. The Perl would simply spawn the .exe process, accept it's output and send it back out to the browser.

That having been said, I expect tsdragon is correct, "... it shouldn't be difficult to do the same thing in perl". If you are going to be doing CGI, go Perl. It will be SIMPLER to write and more portable.




keep the rudder amid ship and beware the odd typo
 
Many web hosting companies use a CGI wrapper for Perl scripts that prevents the common user from executing system calls... so, unfortunately, goBoating's technique probably won't work. Plausible in theory, though.

If you don't want to go through the hassle of porting the code to Perl (moreover, the paradigm shift to an interpreted language), you may play with this idea... There is a distinction between CGI programs and Perl and that distinction may allow you to simply rename the C++ file with a .cgi extension and execute it normally (if you're familiar with Apache, the AddHandler cgi directive doesn't tell Apache to parse everything through the perl interpreter, it's simply the #!/usr/bin/perl that does this).

If that doesn't work.. contact the sysadmin and see if he/she can create a scriptalias directory for you in which every file is treated as a script.

good luck.

brendanc@icehouse.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top