在 Ubuntu 14.04 上使用 Grails 2.4.5 org.codehaus.groovy.runtime.ProcessGroovyMethods时:
def command = "mysqldump -h${databaseProperties.host} -u'${databaseProperties.username}' -p'${databaseProperties.password}' ${databaseProperties.name} " + table
print command
def proc = command.execute()
def oneMinute = 60000
proc.waitForOrKill(oneMinute)
if(proc.exitValue()!=0){
println "[[return code: ${proc.exitValue()}]]"
println "[[stderr: ${proc.err.text}]]"
return null
}else{
return proc.in.text.readLines()
}
我有
[[return code: 2]]
[[stderr: mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect]]
但是当我将 printlined命令复制粘贴到我的 bash 中时,我会收到正确的转储。到底是怎么回事?
我也试过:
将mysqldump更改为完整路径:/usr/bin/mysqldump
将参数作为字符串数组发送,但结果相同。
将命令作为常规字符串发送以执行:
"mysqldump -hlocalhost -u'root' -p'password' database table"
它在系统 bash 中工作,它不作为 ProcessGroovyMethod...