473,246 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

Using PHP to compile uploaded sourcecode with cygwins gcc?

Hello, I have an intresting problem: I want to let users upload sourcecode
and then compile it using my cygwin gcc... But one thing at a time... I
can't get that gcc to execute...

shell_exec("gcc temp.c"); # Doesn't work as that will use MinGW
shell_exec("D:\\cygwin\\bin\\gcc.exe temp.c"); /* Gives some error about dll
stuff (procedure not found I think)*/

So my next though was to open "bash.exe --login -I" and fwrite the
commands... But that still tries to use the mingw compiler it seems...Guess
there's some environiment problem... So I figured I could use virtual() to a
cgi script with this as first line:
#!D:/cygwin/bin/perl
and then use the perl open(), with |/cygdrive/d/bin/gcc.exe temp.c as
argument... Seems like it executes the right compiler then, but then I get
millions of errors caused by *.h can't be opened (yes, the source tries to
include them), so I though about passing -B /usr/include to it... But those
errors still appear... Also, it feels somewhat bad to use virtual() to call
perl scripts, so I was wondering if you ppl have some nice idea on how I
would do it?

Paths:
Cygwin: d:\cygwin
PHP: C:\PHP (4.3.3, zip from php.net, installed as Apache 1.3.28 module)
Apache: D:\Apache (installed using .msi package, as service)
Perl: D:\perl\bin\perl.exe (or D:\cygwin\bin\perl.exe)
Script: D:\www2\compile.php, D:\www2\compiling\compile_cyg.cgi
Sourcecode: D:\www2\compiling\temp.c (yes, only one file yet, that's a later
problem)

pwd returns I'm in the 'compiling' folder, in the php script, I chdir() to
get into that folder...

Can anyone help, please? Security is not a concern, it's private, and it's
for learning purposes mostly... I use winXP home... I can install stuff like
I want, that's not a problem... Thanks in advance!
--
// DvDmanDT
MSN: dv******@hotmail.com
Mail: dv******@telia.com
Jul 17 '05 #1
4 4304
On Sat, 20 Sep 2003 15:45:14 +0000, DvDmanDT wrote:
Hello, I have an intresting problem: I want to let users upload sourcecode
and then compile it using my cygwin gcc... But one thing at a time... I
can't get that gcc to execute...

shell_exec("gcc temp.c"); # Doesn't work as that will use MinGW
shell_exec("D:\\cygwin\\bin\\gcc.exe temp.c"); /* Gives some error about dll
stuff (procedure not found I think)*/
my guess is:
find out what environment variables need to be set in order for window's
shell to find the correct DLLs, and set them before calling shell_exec

it's just a guess though, I'm not sure that's the problem.


So my next though was to open "bash.exe --login -I" and fwrite the
commands... But that still tries to use the mingw compiler it seems...Guess
there's some environiment problem...


well what's the default compiler when you run a bash shell under cygwin ?

--
luc wastiaux
email: luc-at-4002-dot-org
jabber: lu*@jabber.4002.org

Jul 17 '05 #2
In cygwin, /bin/gcc or /usr/bin/gcc is used (same file, it's linked it
seems)... This works as Cygwin sets it's own PATH variable... But for some
reason, it seems like that doesn't happend from Apache/PHP/Perl.. The only
env var that should have to be set is Path, and that should include
D:\cygwin\bin which it does... Here's my PATH (only first items as it's
pretty long):

c:\develop\mingw32\bin;D:\djgpp\bin;D:\cygwin\bin; D:\cygwin\usr\sbin

PATH is the same for system and my account... Also, what would my `` command
be? I have serious problems... Also, what dir should I try to include (I
mean, /usr/include or D:\cygwin\usr\include)?

Thanks for your help
--
// DvDmanDT
MSN: dv******@hotmail.com
Mail: dv******@telia.com
"luc wastiaux" <lu*@nospam.invalid> skrev i meddelandet
news:pa****************************@nospam.invalid ...
On Sat, 20 Sep 2003 15:45:14 +0000, DvDmanDT wrote:
Hello, I have an intresting problem: I want to let users upload sourcecode and then compile it using my cygwin gcc... But one thing at a time... I
can't get that gcc to execute...

shell_exec("gcc temp.c"); # Doesn't work as that will use MinGW
shell_exec("D:\\cygwin\\bin\\gcc.exe temp.c"); /* Gives some error about dll stuff (procedure not found I think)*/


my guess is:
find out what environment variables need to be set in order for window's
shell to find the correct DLLs, and set them before calling shell_exec

it's just a guess though, I'm not sure that's the problem.


So my next though was to open "bash.exe --login -I" and fwrite the
commands... But that still tries to use the mingw compiler it seems...Guess there's some environiment problem...


well what's the default compiler when you run a bash shell under cygwin ?

--
luc wastiaux
email: luc-at-4002-dot-org
jabber: lu*@jabber.4002.org

Jul 17 '05 #3

"DvDmanDT" <dv******@telia.com> schreef in bericht
news:LI*******************@newsc.telia.net...
In cygwin, /bin/gcc or /usr/bin/gcc is used (same file, it's linked it
seems)... This works as Cygwin sets it's own PATH variable... But for some
reason, it seems like that doesn't happend from Apache/PHP/Perl.. The only
env var that should have to be set is Path, and that should include
D:\cygwin\bin which it does... Here's my PATH (only first items as it's
pretty long):


Try it with a batch file that sets the required path and call this with
shell_exec. This batch file could look something like the following:

SET path = %path%;D:\cygwin\bin;D:\cygwin\usr\sbin
D:\cygwin\bin\gcc.exe %1

Call it as: 'name_of_batch_file.bat source.c'
HTH,
JW

Jul 17 '05 #4
Why set it last in the path? First would be better... *testing* damn,
refuses to include the header files... -B seems to be simply ignored... :S

--
// DvDmanDT
MSN: dv******@hotmail.com
Mail: dv******@telia.com
"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> skrev i meddelandet
news:3f***********************@news.euronet.nl...

"DvDmanDT" <dv******@telia.com> schreef in bericht
news:LI*******************@newsc.telia.net...
In cygwin, /bin/gcc or /usr/bin/gcc is used (same file, it's linked it
seems)... This works as Cygwin sets it's own PATH variable... But for some reason, it seems like that doesn't happend from Apache/PHP/Perl.. The only env var that should have to be set is Path, and that should include
D:\cygwin\bin which it does... Here's my PATH (only first items as it's
pretty long):


Try it with a batch file that sets the required path and call this with
shell_exec. This batch file could look something like the following:

SET path = %path%;D:\cygwin\bin;D:\cygwin\usr\sbin
D:\cygwin\bin\gcc.exe %1

Call it as: 'name_of_batch_file.bat source.c'
HTH,
JW

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The...
5
by: babuyama | last post by:
Hi, Is there a way to obtain library name at compile/preprocessor time? Assuming that the compilation unit, myfile.c is part of mylib.a, from myfile.c code at compile/preprocessor time, I would...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
1
by: Digital Fart | last post by:
what ms product do i need to buy to compile programs for the compact framework and mobile devices? looking at there vs products i only see the architect version. Very expensive as we only need...
6
by: Julien | last post by:
Hello, I have some files located in a file server and managed by a SQL database from a web based interface using ASP + VBSCRIPT technology. I need to automatically copy those files to a web...
6
by: Joel H | last post by:
We have several settings in web.config that are different on the developer side than the production side. Our website sourcecode is under sourcesafe control, so before we code, we check out the...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: Alien | last post by:
Hi, I am new to PHP and trying to move a zip file from one directory to another. I researched on the web on this and all fingers pointed to this rename() function. I tried writing a PHP script...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.