LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-18-2008, 02:36 PM   #1
techsavvy
LQ Newbie
 
Registered: Jun 2008
Posts: 4

Rep: Reputation: 0
Require Some Guidance regarding Online Complier project


Hi everyone,

I am working on an Online complier project. I am stuck in between, so want help from you guys. Does anyone have an idea on how can I open a linux terminal through CGI scripts or PHP scripts on server side ?

Description: The IDE for writing programs is an online application, somewhat like google docs, so a user writes his code and has various buttons given for compilation and running code etc. Every thing should be done with the help of server which uses gcc as the backend compiler.
The server has a script(CGI / PHP) which runs whenever it gets any request from the client's browser.

Meaning when a user presses compile button at client side, the request should go to server, which runs a script. That script should now open the terminal and run gcc filename.c command there.

So how can I accomplish this task ?
 
Old 06-18-2008, 03:55 PM   #2
timnp
Member
 
Registered: Feb 2008
Location: London
Distribution: FC8, FC9, Centos 4, Centos 5, Knoppix
Posts: 52

Rep: Reputation: 17
I dont know exactly what it is you want to achieve...

If you are looking for a way to pass certain customisable commands (ie, the commands to do your compiles/run code etc,) then you should look at the following php functions. They are all slightly different in how they handle the output from your commands so you should read carefully...

http://us3.php.net/manual/en/function.system.php
http://us3.php.net/manual/en/function.exec.php
http://us3.php.net/manual/en/function.passthru.php

Make sure that if you are passing any arguments to your commandline that have been supplied by the user that you run them through escapeshellarg() first:

http://us3.php.net/manual/en/functio...peshellarg.php

If you wanted to have an interactive command line type thing where the user interacts directly with the command line then im not sure that there is an 'easy' way to do this but perhaps you can build something with the commands above?

Hope that helps or at least points you in the right direction.

Timnp
 
Old 06-23-2008, 05:44 PM   #3
techsavvy
LQ Newbie
 
Registered: Jun 2008
Posts: 4

Original Poster
Rep: Reputation: 0
hey thanks,

This actually did not solved my problem but brought me to right path. Earlier I was thinking that for a PHP script, to run commands, it will have to open a terminal. Anyways...

Quote:
Originally Posted by timnp View Post
I dont know exactly what it is you want to achieve...
Timnp
Now, what I want to achieve is - I want to write a PHP script that uses gcc command and compiles a file passed to it. And what ever be the result of compilation(error,warning etc...) be stored in a new temporary file. Can anyone explain how this can be done?

I hope now my question is clear.
Actually earlier I was asking the wrong question as I wasn't on right path and didn't had any idea about how PHP works. I hope there isn't any confusion now as far as question is concerned.
 
Old 06-24-2008, 06:57 PM   #4
timnp
Member
 
Registered: Feb 2008
Location: London
Distribution: FC8, FC9, Centos 4, Centos 5, Knoppix
Posts: 52

Rep: Reputation: 17
Well I can't help specifically because I am not familiar with GCC, please can you post some examples of the types of command you want to run?

Regards,

timnp
 
  


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
Urgent require help & guidance on displaying for presentation vitalstrike82 SUSE / openSUSE 10 03-02-2008 09:48 PM
Apache2 Require user with Require group Russianspi Linux - Server 2 01-30-2008 11:21 AM
online project management stripe21 Linux - Software 2 01-18-2008 05:51 AM
C complier rehan999 Linux - Software 6 10-27-2007 11:26 PM
newbie require guidance arunsri Slackware 7 03-18-2005 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:41 PM.

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