您好我有这个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")
~
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 );
}
我的.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
当我尝试在drupal apache中执行时给出了这个错误:
sh: 1: frapi-generate-keys: not found
然后我尝试给出绝对路径:
$output = shell_exec( '/home/admin1/frapid/bin/frapid-generate-keys '. $form_state['values']['api_manager_project_root'] );
但仍然有误:
/usr/bin/env: groovy: No such file or directory
答案 0 :(得分:0)
好的...... Apache为PATH变量提供了不同的文件配置。 对于ubuntu,文件是/ etc / apache2 / envvars,这里我们可以'导出'我们的变量