Search code examples
phpc++perlcgi-bin

How to call c++ binary from Perl or PHP (CGI-BIN using Apache on Linux )?


I have a website cgi-bin program that is written in c++.

Unfortunately the website provider for my friend's site only allows Perl or PHP cgi-bin scripts.

Is there an easy way to simply have a very small Perl or PHP wrapper that just calls the c++ compiled binary?

Would the c++ program still be able to read from stdin for POST commands or would it have to be read by the Perl or PHP and then forwarded.


Solution

  • You can use Perl's backticks or "system" commands to run shell commands. Also, perl has a lot of "Inline" classes that allow you to write code in other languages to be called in perl, including one for C++. If you can't find something that works, maybe you can make your own wrapper using that package.