Running a C++ Library Function or Executable Using JavaScript

P

Peter Lauren

I have an object library from code that was written in C++. Is there
a JavaScript call that would enable me to run a function from the
library, or a C++ derived executable, from a web page?

Thanks,
Peter.
 
D

Denis McMahon

I have an object library from code that was written in C++. Is there a
JavaScript call that would enable me to run a function from the library,
or a C++ derived executable, from a web page?

You've asked this question in both php and javascript newsgroups.

PHP runs on the server
Javascript usually runs on the client

Where do you expect this object library to be? On the client, or on the
server?

Rgds

Denis McMahon
 
P

Peter Lauren

You've asked this question in both php and javascript newsgroups.

PHP runs on the server
Javascript usually runs on the client

Where do you expect this object library to be? On the client, or on the
server?

Rgds

Denis McMahon

The object library will be server side but I want the client to be
able to run the executable or function from the browser.

Thanks,
Peter.
 
E

Erwin Moller

PHP exec() seems to be the way to go. http://us2.php.net/function.exec

I would approach this follows:
1) log into a shell on your server
2) become www-data (or whatever user runs PHP on your server).
('sudo su www-data' or something like that)
3) Make a command that actually works and successfully calls your C++
lib and produces the output you expect.
4) Once you figured that out, try it via PHP. (I am not sure if exec()
will do what you want, if not, have also a look at passthru() if you
receive binary data back from the process.
5) Make sure you are not creating a securityhole. Have a look at
functions like escapeshellcmd()

6) Once the above all works, you can use it from the clientside via
JavaScript. In case you want to make a call from the client, use
XMLHTTPREQUEST.
In case you only run it at the server, run it and use its output
appropriately. You didn't give enough information here.

Regards,
Erwin Moller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top