Not a solution per se but I’d suggest ack is overkill for what you’re trying to do here. Ack is optimized for searching code — you’re searching a simple CSV data file. Have you tried using grep? I bet you could build a grep pipeline into sed or cut that would give you in Java just what you want from that CSV line.
Mike Kelly Tech DNA On Saturday, April 24, 2021 at 9:07:02 AM UTC-7 [email protected] wrote: > Hi Andy, > Thanks for your quick reply > > * Can you see any of the output from ack when you run it in Eclipse? Do >> you get an error message?* > > > When I run the command from Eclipse > > "ack 11290013 UIM.csv" > > I get only the following error > > org.apache.commons.exec.ExecuteException: Process exited with an error: 1 > (Exit value: 1) > > and no more... this is the section code: > > String line = "ack 11290013 UIM.csv"; >> CommandLine cmdLine = CommandLine.parse(line); >> DefaultExecutor executor = new DefaultExecutor(); >> executor.setWorkingDirectory(new >> File("/Users/davidevichi/csvkit_tutorial/")); >> int exitValue = executor.execute(cmdLine, procEnv); >> System.out.println("Process exit code: " + exitValue); > > > > >> *My first thought, without knowing anything else, is that somehow you >> have your PATH different between Eclipse and your shell. Or, it could be >> PERL5LIB, and ack can’t find the standard libraries.* > > > I can confirm that the PATH variable is the same between Eclipse and > shell. Initially it wasn't, then I found a way to set it up.. > > Map<String, String> procEnv = EnvironmentUtils.getProcEnvironment(); >> procEnv.put("PATH", "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"); > > > maybe it is PERL that needs to be configured properly but i don't know how > to do it. > > >> *What if you just run “ack -h”, where it doesn’t do anything but show a >> help screen?* > > > I had not tried this test in fact. I confirm that "ack --help" WORKS > perfectly in Eclipse! (invoked in the same way as above). > > Some detail about the first ack command: > - UIM.csv it's a very huge file 2,5GB > - "11290013" it's a product id and I want to read the line containing the > product details. > > Thanks in advance > Best Regards > > > Davide > > > > Il giorno sab 24 apr 2021 alle ore 17:24 Andy Lester <[email protected]> > ha scritto: > >> > >> > I need to run the "ack" command directly from a Java program on >> Eclipse, it just doesn't work and returns exit code = 1. >> > If I run the same shell command, it works perfectly. >> >> >> Can you see any of the output from ack when you run it in Eclipse? Do >> you get an error message? Can you run other things than ack from inside >> Eclipse? >> >> My first thought, without knowing anything else, is that somehow you have >> your PATH different between Eclipse and your shell. Or, it could be >> PERL5LIB, and ack can’t find the standard libraries. >> >> >> > >> > - I tried to run eclipse as super user, the "ack" command is recognized >> but something goes wrong. >> >> We need more details about the “something goes wrong”. It doesn’t sound >> like you’re doing anything weird. >> >> What if you just run “ack -h”, where it doesn’t do anything but show a >> help screen? >> >> I think if we can get some more details, we’ll get this figured out. >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "ack users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ack-users/93AC687F-E2F6-4529-BC43-B8114AE89EC9%40petdance.com >> . >> > > > -- > > -- You received this message because you are subscribed to the Google Groups "ack users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ack-users/6657195b-8b70-4059-8a67-a744ad008c5cn%40googlegroups.com.
