在php中执行我自己的groovy脚本

时间:2022-11-11 07:16:02

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

1 个解决方案

#1


0  

Ok... Apache has a different file configuration for the PATH variable. For ubuntu the file is /etc/apache2/envvars, here we can 'export' our variables

好的... Apache为PATH变量提供了不同的文件配置。对于ubuntu,文件是/ etc / apache2 / envvars,这里我们可以“导出”我们的变量

#1


0  

Ok... Apache has a different file configuration for the PATH variable. For ubuntu the file is /etc/apache2/envvars, here we can 'export' our variables

好的... Apache为PATH变量提供了不同的文件配置。对于ubuntu,文件是/ etc / apache2 / envvars,这里我们可以“导出”我们的变量