472,331 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

output from executing external programm

Dear all,

I am a newbie in Java, I got the following problem:
I am going through a list of directories. The programm looks inside each directory for specific files and writes them in an File-array. Then it goes through this array and executes the external programm "naccess". naccess takes a file as input and produces 4 output files. Unfortunatly the result files are not in the directory where the input file is (/home/tj/test), they are in the java directory (/home/tj/workspace/Set).
Is there a way to tell java to execute the programm in the acutal folder?
I paste some of the source code, hope it is not to much/less:

public void scanDir(File filePath){

//Just get zipped Files
FileExtensionFilter filter = new FileExtensionFilter(".pdb");

String[] entries = filePath.list(filter);

//entry contains no files
if (entries == null || entries.length < 1){
//go through file list
for (int i = 0 ; i < entries.length ; i++){

File entry = new File(filePath, entries);

if (entry.isDirectory()){
String[] programm = {"/bin bash -c '/home/tj/naccess'", entry.getAbsolutePath()};
}//else scanDir()

//positiveSet.execute is pretty much an adaption of the streamgobbler class which can be found here:

Sadly there is no switch in naccess to redirect the output, it always writes the result files in the executing folder.

Thanks very much,
Aug 18 '06 #1
2 1854
Make a shell including the change to the good directory and the call to naccess, then call this shell in your program instead of naccess.

May that help

Aug 23 '06 #2
I finally fixed the problem with giving the actual working directory to runtime.exec. But thanks for your help, keep this in mind!

Aug 24 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Avi Kak | last post by:
Is there a Python function in any of the standard-distribution modules that does what the backticks do in Perl? I want to run an external...
by: Yuan HOng | last post by:
In my program I have to call an external program and parse its output. For that I use the os.popen2 function, and then read the output stream. ...
by: TIM | last post by:
for example i have one simple programm int main() { int test = NULL; while(1){ printf("%d\n",test); getch(); test++; }
by: rilian | last post by:
For those encountering the 'Error executing child request for...' error, the following may bring some light on the problem. It is possible that the...
by: google | last post by:
Hi everyone, >From my WinForms app I am executing an external process. It turns out that I have replaced the EXE of the external process with a...
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't...
by: Ilias Lazaridis | last post by:
IDLE has an output format like this: <type 'object'> <type 'type'> <type 'type'> How can I customize it to become like that: <type...
by: mamoon | last post by:
hi all, i am facing a serious problem in running JDBC programm in Apache server environment. Background Information- 1, OS: Enterprise Linux4...
by: qwertycat | last post by:
Is it possible to execute programs in a PHP script without waiting for the output and successfully ending the PHP script without ending the...
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.