Saturday, July 31, 2010

How to install Matlab on ubuntu server 10.04 via command line

So I did not have x-server install on the server and it was not allowing me to do the GUI install. So instead I tried:

./install -t


for the text install but I got an error after the license agreement:
update/bin/glnxa64/xsetup: error while loading shared libraries: libXp.so.6 cannot open shared object file: No such file or directory

I did this:

apt-get install libxp6

and then it worked just fine using ./install -t
Hopefully this saves somebody some time, and stops them from doing a ubuntu-desktop install on a server just to install Matlab

Thursday, July 8, 2010

True multithreading in PHP! Spawn new threads in webpage

Ok, so I searched around for this and I was disappointed, I could not find true multithreading in PHP. Well here is my solution. You know how you can call php from the command line in linux/unix? Well you can do a system call to a php function, hide the output and break off of it and come back to the website and your php script will continue executing in the background.

Here is an example:

So from the command line I can do:

php -r 'PUT_YOUR_PHP_CODE_HERE_WITHOUT_ESCAPES;'

well there is no reason you can't call the a system call from your website, so I am doing something like this:

$exec_string="php -r 'PUT_YOUR_PHP_CODE_HERE_WITHOUT_ESCAPES' > /dev/null 2>&1 &";
exec($exec_string,$output);


The command: 2>&1 & at the end is what I am using the escape the string rather than waiting for it to finish.

$exec_string="php -r 'mail(\"".$_POST['user']."\",\"".$string1."\",\"".$bericht."\",\"".$string2."\");' > /dev/null 2>&1 &";
exec($exec_string,$output);