Hi. I'm running into what seems to be some sort of limitation on the number of arguments passed to the execute() method. I have a Groovy class that calculates a set of database tables, and then executes the Postgres pg_dump command, where each table is specified with the -t option. I'm basically trying to dump the database, but only the specified tables. I'm using the List version of execute (found an example on the codehaus.org site). A little simplified, the code looks something like this:

// Returns a list like ["-t", "foo", "-t", "bar", "-t", ...]
def tableArgs = tablesToDump()
["$pgDump", '-a', '-n', 'public', '-f', "${tmpFile.path}", '-h', "$dbHost", '-p', "$dbPort", '-U', "$srcDbUser", '-d', "$srcDb"].plus(tableArgs).execute()

In some cases, the list of -t table pairs can get quite long. So I'm running into situations where the output from the pg_dump command doesn't contain the data for some tables. The command succeeds with no errors, but I'm not getting the expected output from the database. However, if I instead of calling execute(), just print the command string and execute it manually from a shell, then things work. This makes me think that I'm running into some limitation of the execute() method. I have scoured the Groovy Lang/GDK documentation, but haven't found any mentioning of that. I'm guessing that Groovy uses the Java Runtime.exec() method under the covers, but I'm not aware of any documented limitations for Runtime.exec() either.

I like the convenience of using Groovy's execute() mechanism with the easy processing of stdin/stdout/stderr, so I'd like to stick to it unless some potential limitation forces me not to. In case it's of relevance, I'm running on MacOS 10.10.2, with Oracle Java version 1.8.0_25-b17, and Groovy 2.3.10. Any help is much appreciated. Thanks,

-H

Reply via email to