Entry
How do we execute .cpp or .c file, ( stored as BLOB in db) upon reading them
Jul 10th, 2002 03:32
Saryon, Rahman Athaur,
The easiest way (if not only way) would be to put the blob into a var,
writing that var to a file, compiling the file, and then executing
the executable.
pseudocode:
<?
database_connect(server, port, username, pass);
query = "select code from table";
database_execute(query);
code = database_get_data();
fp = open_file(tempfilename.".c");
write_to_file(fp, code);
fclose(fp);
system('make tempfilename;chmod +x tempfilename');
$recv = system('tempfilename');
unlink(tempfilename);
unlink(tempfilename.".c");
database_close_connection();
?>
Have fun.