I am trying to build a server where users can submit a query, and visualize the output. Till now everything is okay. I have seen that it is possible to run a workflow by command line using for example :
I have build all the php, html and javascript stuff. Now the last difficulty is to run the workflow.
I've seen that it exists a php function to run bash commands, called exec().
But when I use it, it doesn't seem to work well. Before using the command to run the workflow in php I have tested it in a simple terminal, it works well.
Do you have any idea or suggestion to solve my little problem ?
exec() is one of the risky functions you should only ever use in limited intranet contexts, and even there very sparingly. Given that it's both dangerously convenient and risky I believe you need to explicitly activate it in the php.ini - some generic PHP documentation should help you with that. I also imagine that you'll need to take care of memory allocation, since exec() normally won't trigger software of that magnitude. Finally, there might be an issue with the command-line syntax KNIME uses - it's been years since I touched this stuff, but there might be special characters in need of escaping involved. But again, that's something for PHP-specific support I cannot provide offhand, sorry. :-)
Good luck! The amount of comments on http://php.net/manual/en/function.exec.php suggests it's quite a challenge. A "lessons learned" article would be helpful indeed, looking forward to that!
It seems that it is possible according to the link provided by Ergonomist, but it depends on the host operating system (windows or unix).
It is indeed possible to use the class COM and Run() function to create ajob which will be ran independently from the initial php script. This class is available on on window's php versions.
For unix, it seems possible to use nohup and exec(). I am still investigating to find a proper way to use it (as I am working on unix).
In all cases (windows or unix), Ergonomist says right about a character escape issue. For windows, it seems that ' ^ ' is the necessary to escape special characters seuch as ' " ' in :
This time using exec() and nohup, I am able to run knime using the command line from the batch mode. But this time I am having a problem with Java Runtime Environment :
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f5ecac4d4e9, pid=9123, tid=140080904931072
#
# JRE version: Java(TM) SE Runtime Environment (7.0_60-b19) (build 1.7.0_60-b19)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.60-b09 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libgdk-x11-2.0.so.0+0x6e4e9] gdk_window_enable_synchronized_configure+0x9
#
# Core dump written. Default location: /opt/lampp/htdocs/server/requests/29/core or core.9123
#
# An error report file with more information is saved as:
# /opt/lampp/htdocs/server/requests/29/hs_err_pid9123.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
Hi there,
I know it has been a while since you were discussing this issue. I was reading your post recently and following through but I still have troubles with executing my knime project through command line and PhP. It is a Batch Executer error “IO error while loading the workflow”.
I cannot address the problem. in addition in your work flow directory, did you stop at Knime_project folder or did you proceed to “workflow.knime”?
MyWorkflow is the directory of your Knime project/workflow. (This usually contains directories of the nodes you used, as well as the workflow.knime file).
I am also trying to call a Knime workflow from PHP using exec(), however I am using Windows.
The path in the exec function below successfully invokes Knime when it is entered directly into the command line, but is not working when used with exec() in PHP. Note that the 'knime' at the beginning of the path is set to the path of the knime.exe file.