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){
return;
}
//go through file list
for (int i = 0 ; i < entries.length ; i++){

File entry = new File(filePath, entries);

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

//positiveSet.execute is pretty much an adaption of the streamgobbler class which can be found here:
http://www.javaworld.com/javaworld/j...229-traps.html

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

Thanks very much,
Thomas
Aug 18 '06 #1
2 1854
PLA
44
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

Pascal
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!

Cheers,
Thomas
Aug 24 '06 #3

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

Similar topics

4
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...
3
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. ...
6
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++; }
0
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...
0
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...
83
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...
20
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...
0
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...
2
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...
0
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...
0
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...
0
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...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
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...
0
jalbright99669
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...
0
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. ...
2
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...
0
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.