![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Apr 2009
Posts: 6
OS: linux
|
Dear all,
I have a huge c++ program (gcc compiled) that runs on a linux console. It's an interactive program in the sense that it requires the user to enter some information through the console in order to process and give some complicated output (cout, cin). For a naive illustration, imagine a program asking you for your age on the console, you enter it and the program gives you your year of birth. The same, but a bit more complicated is my program. My problem is just that I need it to be executed in a browser by people on the other side of the world. I do have a server where it can run, but I don't know how to make the necessary interface. Could someone of you please help me out? I thank you in advance |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#3 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,888
OS: Vista, various linux distros
|
Re: hot to put a c++ program in the web ?
It cannot be executed in a browser sorry. No exe could. It could be executed by the server, but the user would not be aware of this (so would not be able to input data). And you could have the user download the exe and execute it on their machine, but what you want to do can't be done.
It's also illogical as you've compiled for linux and the majority of the world use windows, if this were possible you'd be crashing pcs everywhere ;P. Why do you need it to run like this? it's possible to take the input, then push that into your program using a server side language(e.g. PHP). Cheers, Jamey |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Apr 2009
Posts: 6
OS: linux
|
Thanks
Hi guys,
Thank you for your reply. I think I'm going to do it as you say: I'll pick up the input in a normal textbox and then push it into my executable. I thought though, that there might be a way (maybe through a java console or something similar) to execute my program from the web. Of course, it'd run on the server (that, as most of the internet servers, would be linux/unix), and a sort of console would be just an interface. I thought that could be possible. However, I'm not an expert. That's why I'm asking here. Anyway, I think the php/perl solution is the simplest one. Thanks again. |
|
|
|
|
|
#5 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,888
OS: Vista, various linux distros
|
Re: hot to put a c++ program in the web ?
Hey again, there are ways to do it without re-loading the page but all would use the simple method: Get Input, Send HTTP Request, Inject Input into program. Basically using AJAX/Java you could fool the user into thinking they're using the program but it would be just as complicated as re-writing the program for a different language.
Good Luck coding this, if you need any help please post back =] Cheers, Jamey |
|
|
|
|
|
#6 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,888
OS: Vista, various linux distros
|
Re: hot to put a c++ program in the web ?
MegaSpam. Anyone who read the above post, sites like that are registered to by the examining boards who test you and moderate your coursework, the have an index of each of the pieces written and compare your coursework with them. If your coursework has more than an 85% match you get disqualified immediately. if it's more than 60% then you're put up for report, in which they'll question your knowledge on the subject in an interview and can even put you up against a polygraph test. It's easier to read a book and write an assignment than to get through that. Do not click the link.
The site may not even be legitimate, note "david" in the name and yet the end of the message is "cheers! emily"? haha. Spammer's annoy me, someone please remove. |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Apr 2009
Posts: 6
OS: linux
|
Hi Jamey,
Thanks for you help (your last post was maybe an error, wasn't it?) Yet I have still some problems. I want to run my c++ program in background by using the command $cmdstr = "./myc++program > /dev/null 2> /dev/null & echo $!"; $PID = shell_exec($cmdstr); I need the PID because I want eventually to terminate the program: exec("ps " . $PID, $state); if(count($state) >= 2) ** exec("kill -9 " . $PID); echo "Program terminated!"; } The problem is that the condition in the IF (i.e. verifying whether my program is still running) is never fulfilled. This tells me that either a) my program is never started or (even worse) b) my program does run in background, but I can't terminate it. Can you help me? Cheers, Saul |
|
|
|
|
|
#8 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,888
OS: Vista, various linux distros
|
Re: hot to put a c++ program in the web ?
What does $state return?
And does the program not just finish executing and close? oh and my last post was because a user/bot posted some spam about getting GCSE/A level assignments done online. But that's gone now. |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Apr 2009
Posts: 6
OS: linux
|
Re: how to put a c++ program in the web ?
Hi Jamey,
I'm here again. The variable $state returns an array containing the result of "ps"; in the current case, it returns only PID TTY TIME CMD that is, only one line, that's the reason why it never enters the IF clause. Something I didn't mention before is that the php script that start my c++ program and the script that kills it are different files. In the meanwhile, I noticed that this is perhaps the problem. One php script starts the program in background, but once the php file is executed, it automatically terminates my c++ program. Thus, a reasonable question could be whether there is a way to mimic the console command ...> ./myc++program & so that it keeps running in the background even after I finish the php program. Do you think that "nohup" might do it? Thanks! |
|
|
|
|
|
#10 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,888
OS: Vista, various linux distros
|
Re: hot to put a c++ program in the web ?
Take a look at this.
It might help. I think that is the problem anyway, and that the post that link takes you to might get around it =] Cheers, Jamey |
|
|
|
|
|
#11 (permalink) |
|
Registered User
Join Date: Apr 2009
Posts: 6
OS: linux
|
Re: hot to put a c++ program in the web ?
Hey Jamey, thanks for your help. My program seems to work properly now. There are still other security issues that I have to fix, but I think that by using SESSIONS all problems will be gone. Thanks again!
|
|
|
|
![]() |
| Thread Tools | |
|
|