[英]Executing my own groovy script in php
Hi I have this groovy script (in $FRAPID_HOME/bin) and I want to call it in Drupal: 嗨,我有这个groovy脚本(在$ FRAPID_HOME / bin中),我想在Drupal中调用它:
#!/usr/bin/env groovy
def cli = new CliBuilder(usage: 'frapid-generate-keys projectPath')
def opt = cli.parse(args)
if ( opt.h || opt.arguments().isEmpty() ) {
cli.usage()
return
}
def path = "."
println("Generating keys...")
def frapid = new Frapid()
println '---->' + opt.arguments()[0]
println("Keys genarated")
~
the php code is this: php代码是这样的:
function api_manager_generate_keys_form_submit( $form, &$form_state) {
$output = shell_exec( 'frapid-generate-keys '. $form_state['values']['api_manager_project_root'] );
drupal_set_message( $output );
}
my .bashrc configuration is this: 我的.bashrc配置是这样的:
export FRAPID_HOME=/home/admin1/frapid
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export GROOVY_HOME=/home/admin1/groovy-2.0.1
export CLASSPATH=$FRAPID_HOME/classes:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$GROOVY_HOME/bin:$PATH
when I tried to execute in drupal apache gives me this error: 当我试图在drupal apache中执行时给了我这个错误:
sh: 1: frapi-generate-keys: not found
then I tried giving the absolute path: 然后我尝试给出绝对路径:
$output = shell_exec( '/home/admin1/frapid/bin/frapid-generate-keys '. $form_state['values']['api_manager_project_root'] );
but is still in error: 但仍然是错误的:
/usr/bin/env: groovy: No such file or directory
Ok... Apache has a different file configuration for the PATH variable. 好的... Apache为PATH变量提供了不同的文件配置。 For ubuntu the file is /etc/apache2/envvars, here we can 'export' our variables 对于ubuntu,文件是/ etc / apache2 / envvars,这里我们可以“导出”我们的变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.