嗨,我有这个 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