anna82 Posted June 1, 2010 Share Posted June 1, 2010 Hi, I have to develop a website that enables the execution of a matlab program. I would like to know whether or not the option I am trying to implement is feasible and/or if this depends on the type of license that I have. In particular, I would like to be able to lauch a script from php in this way: system('./script.sh') where the script contains the following lines: whoami matlab -nodisplay -nosplash -r "main;quit;" Since the installed type of license is "stand-alone named user installation", I can only run matlab from the enabled user. For thid reason, I have changed the apache user from the default www-data to the matlab user. The problem is that, if I go to the webpage of my application (the php file), I have the license manager error even if the user displayed by the "whoami" command is the correct one. Is the option I am trying to develop feasible? Does any of you have ever done something similar? Thank you Anna Quote Link to comment https://forums.phpfreaks.com/topic/203507-launch-matlab-from-php-with-an-apache-server/ Share on other sites More sharing options...
JonnoTheDev Posted June 1, 2010 Share Posted June 1, 2010 If you have php installed as an apache module then you will have issues. Compile as CGI. http://docs.joomla.org/Should_PHP_run_as_a_CGI_script_or_as_an_Apache_module%3F#What_is_the_difference_between_CGI_and_apache_Module_Mode.3F Quote Link to comment https://forums.phpfreaks.com/topic/203507-launch-matlab-from-php-with-an-apache-server/#findComment-1066092 Share on other sites More sharing options...
Daniel0 Posted June 1, 2010 Share Posted June 1, 2010 Run it like this: sudo -u TheMatlabUser /path/to/the/script.sh Then add the following to the sudoers file: TheMatlabUser ALL=NOPASSWD: /path/to/the/script.sh Quote Link to comment https://forums.phpfreaks.com/topic/203507-launch-matlab-from-php-with-an-apache-server/#findComment-1066164 Share on other sites More sharing options...
anna82 Posted June 4, 2010 Author Share Posted June 4, 2010 Hi all, Thank you for the suggestions...unfortunately it still doesn't work. I have tried both options but it still gives me the license error message. Moreover, the idea to launch the .sh file with the command: sudo -u matlabuser ./script.sh after having added to the sudoers file : matlabuser ALL=NOPASSWD: pathto script.sh does not work even when I launch it in the terminal from root: I still get the license error message. Thank you very much for the help Quote Link to comment https://forums.phpfreaks.com/topic/203507-launch-matlab-from-php-with-an-apache-server/#findComment-1067669 Share on other sites More sharing options...
Daniel0 Posted June 4, 2010 Share Posted June 4, 2010 Try using the -H option as well. That will override the HOME environment variable. Quote Link to comment https://forums.phpfreaks.com/topic/203507-launch-matlab-from-php-with-an-apache-server/#findComment-1067673 Share on other sites More sharing options...
anna82 Posted June 7, 2010 Author Share Posted June 7, 2010 Hi, finally it works!!! I run, as you suggested me, sudo -H -u matlabuser pathtothescript.sh and edited the sudoers file with matlabuser ALL= (ALL) pathtothescript.sh Thank you very much for the help! Quote Link to comment https://forums.phpfreaks.com/topic/203507-launch-matlab-from-php-with-an-apache-server/#findComment-1068911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.