Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Running under Ubuntu 64 #4
I'm trying it with Ubuntu 64 without success...
My MakeFile I've changed to this:
I've added this in /etc/mysql/my.conf
Changed the permissions of /usr/lib/mysql/plugin
When I run you example command:
In my case:
This problem is caused by apparmor and i solved it by disabling its profile. This may help http://www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/
And i see a bit difference in the compile sentence, i used this one: "gcc -DMYSQL_DYNAMIC_PLUGIN -fPIC -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o $(LIBDIR)/lib_mysqludf_sys.so"
Now improved somewhat but still not doing what I would like to do. Execute a ffmpeg command or a php script, or even copy a file from a path to another.
I've tested with the compile command that I've posted and yours, both the same result.
Now at least it is working some test commands:
But others like these not:
sys_exec and sys_eval are quite similar, both can run arbitrary code, but the first one returns the exit code and second one the output. Some times i have had to do an explicit cast due to a blob type response (with gui). These are good tests:
Your ffmpeg issue could be a permissions problem, checkout this command:
which ffmpeg | xargs ls -lh
Anyway make sure in the filesystem that it doesn't run.
"cp", "touch", "mv" does not return anything on success. You should check your fs and confirm the copy.
Thank you again daper, I know that the functions are similar but was just to make sure.
Your test worked like expected, returned my ip address in plain and cast columns.
The ffmpeg is under my home folder because I've compiled it and has my user permission:
The "cp", "touch", "mv" does not return and does not do anything. The same command line of my example:
Works in the terminal (copy the file) and does not work under udf sys functions.
Works in terminal but not using "sys_exec"
Ok... In copy command the output code you are receiving corresponds with errors like "No such file or directory" or "Not a directory". You can try something like:
select sys_exec('ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 /home/cassiano/teste/img%03d.jpg &> /tmp/debug-exec.log'
And review the log file in /tmp/debug-exec.log... But i have no more relevant ideas.
Thank you for the time spent trying to help me.
I've tried your idea without success... The command has created the file but it is empty. Maybe is something wrong about permissions, that's the only option in my mind. Some commands run others not. Running "sys_eval('pwd')" return "/var/lib/mysql", running "sys_eval('whoami')" returns "mysql".
Tried to give root privileges to mysql user add the row:
The commands still not working.
I've tried to create a php script to run a system command:
<?php $file = 'results.txt'; $current = file_get_contents($file); $current .= $argv."\n"; $output = system($argv); $current .= $output."\n"; file_put_contents($file, $current); ?>
Again, it works in terminal but not using sys_exec
The weird thing is that this php script create the results.txt inside /var/lib/mysql with the parameter but the index.html it is not copied...
Something is going wrong here, I don't know what yet, but when I run:
SELECT sys_eval('/usr/bin/php5 -e "/var/www/html/do_jobs.php" "ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 img%03d.jpg"');
The frame images are generate successfully but under "/var/lib/mysql", the path returned in my "sys_eval('pwd')" test.
When I try to run:
SELECT sys_eval('/usr/bin/php5 -e "/var/www/html/do_jobs.php" "ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 /home/cassiano/teste/img%03d.jpg"');
Just adding the path "/home/cassiano/teste/" to the image that will be generated nothing happens, the ffmpeg don't generate the images, or even run.
WORKS! finally! I don't have enough knowledge to explain but after giving the permissions to the ffmpeg output folder:
It works! I would like to understand because in the last post I mentioned that I gave root privileges to mysql user.