LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-01-2010, 10:35 AM   #1
magk
LQ Newbie
 
Registered: Mar 2010
Posts: 15

Rep: Reputation: 0
Automate g++ compilation


Hi
I wanted to know whether there is a possibility to automate (in the sense to call g++ compiler from my web application say a jsp page).


What i have is a web application with user signin and problem statements and if the user submits his code i need to get that and compile it using "g++ or javac" and return the result back to the user (say Accepted or WrongAnswer)

Ofcourse i can do this manually. But is there any scripts that i can write to automate it.

Thank you in advance.
 
Old 03-01-2010, 10:57 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Yes, it's possible. What's the point, though?
 
Old 03-01-2010, 11:38 AM   #3
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 79

Rep: Reputation: 1
You could use a CGI script to call the g++, etc.

However all that would do is prove the code compiled, not that it generated logically correct working code.

Mind you I suppose if you take the compilation as an initial part of a larger process you could within the CGI call other testing applications to supply known correct and incorrect data and test the resulting outputs.

I did something similar when I played with C## for a bit. I can't remember the term but basically as you write the application/functions/classes you (or someone else) writes a testing script, that way if you change the code in the future or a problem becomes known, the testing script automates and/or adjusts its validation.

JonXx
 
Old 03-01-2010, 11:57 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by JonathanWilson View Post

I did something similar when I played with C## for a bit. I can't remember the term but basically as you write the application/functions/classes you (or someone else) writes a testing script, that way if you change the code in the future or a problem becomes known, the testing script automates and/or adjusts its validation.

JonXx
They call that 'eXtreme Programming' or 'agile'.
 
Old 03-01-2010, 12:10 PM   #5
magk
LQ Newbie
 
Registered: Mar 2010
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by JonathanWilson View Post
You could use a CGI script to call the g++, etc.

However all that would do is prove the code compiled, not that it generated logically correct working code.

Mind you I suppose if you take the compilation as an initial part of a larger process you could within the CGI call other testing applications to supply known correct and incorrect data and test the resulting outputs.

I did something similar when I played with C## for a bit. I can't remember the term but basically as you write the application/functions/classes you (or someone else) writes a testing script, that way if you change the code in the future or a problem becomes known, the testing script automates and/or adjusts its validation.

JonXx
Thank You for that response.
I basically have my web application in java with jsp n html. And there is java.lang.runtime which i could use to run some commands in linux.

I wanted to know if i could use the whole part of it like

this is the scenario that i want to have and this is where i want help in knowing will i be able to do that
  • User Submits the code say one.cpp
  • I get that and need to call g++ one.cpp. ( this i know can be done using runtime class)
  • Then I have some input files (test cases) with which i need to run that prog. So instead of typing in the inputs i need to give the data in that test case file as input to ./a.out.
  • Then I know that the output of ./a.out can be sent to another file using piping like ./a.out > out.file say.
So i need to know if i can give input to ./a.out from a file and also want to know if there is a way that i could get the g++ compiler error messages like say a syntax error be sent to a file which i can use to indicate the error to the user.
Thank You.
 
Old 03-01-2010, 12:13 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
And again the answer is yes. In fact you've pretty much answered your
own question above:
Quote:
And there is java.lang.runtime which i could use to run some commands in linux.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate Backups waynevnc Linux - Server 2 02-21-2009 10:22 AM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 09:54 AM
Automate Madwifi dauphinfay Linux - Wireless Networking 1 06-13-2006 01:38 AM
How would I automate this? onewhoknows Linux - Newbie 5 06-22-2004 04:49 AM
automate vncserver hoover93 Linux - Software 2 10-23-2003 09:16 AM


All times are GMT -5. The time now is 04:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration