Jump to content


Photo

Running a C program from PHP


  • Please log in to reply
2 replies to this topic

#1 Basab

Basab
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 19 October 2006 - 11:19 AM

Hi all
We need to compile a C program from PHP environment
and to execute the object file of the program.
  We used PHP system commands writing system('cc
programname.c -o objectfile') and
system('./objectfile').It works for small program(we
checked) but
in our application it was able to compile but failed
to run the objectfile.The object file when executed
should give a large(23 MB) binary file.The program is
working properly from the terminal provided we write
the command ' limit stacksize unlimited' before
running the program.The same command 'limit stacksize
unlimited' we tested in PHP but we did not get the
result.
Is it feasible in PHP or we r wrong somewhere? Can u
all please help??
                  Basab Goswami

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 11:39 AM

Running commands through system is the same as running them in the terminal/commandline. You must however note that the commands will be run by the user the webserver (eg Apache) uses and not your user.

#3 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 23 October 2006 - 05:42 AM

You might try

system('limit stacksize unlimited; ./objectfile');

The reason being that the limit is probably reset between system() calls, since system() is opening a new shell each time.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users