473,659 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

output from executing external programm

2 New Member
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
FileExtensionFi lter filter = new FileExtensionFi lter(".pdb");

String[] entries = filePath.list(f ilter);

//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.isDirect ory()){
scanDir(entry);
}else{
String[] programm = {"/bin bash -c '/home/tj/naccess'", entry.getAbsolu tePath()};
positivSet.exec ute(programm);
}//else scanDir()
}//for
}//scanDir()

//positiveSet.exe cute 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 1949
PLA
44 New Member
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
LordChaos
2 New Member
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
2437
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 command and I'd like its output to be captured directly in my Python script in the form of a string object. The function os.system() or any of the
3
1829
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. But the complexity is that the external program gives back its output in a piecemeal manner, with long delays between the outputs. In the main program I want to therefore read the output in a non-blocking manner, to read as many bytes as the child process is spitting out. The question is, how...
6
3217
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
1880
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 page you are transfering/executing to is re-invoking your handler and producing a recursive relationship. The following describes an example of the recursive relationship. ________________________________ //snippet from web.config <httpHandlers>
0
1358
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 newer version and my WinForms app is still executing the old one. I am using Visual Studio 2005 and programming in C#. I have been wrecking my brains for two days and I can't find a possible explanation. These are the things I have tried so far: -Renaming the new EXE and, of course,...
83
7807
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 got any compile problem but when i run it i face some other ploblems which i can not correct.I would appreciated if someone take a look at my programm so as to help me.I tried many times to find out where my mistakes are but i didn't manage something. I have made some comments due to the programm...
20
1905
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 'object'> <type 'type'>
0
1058
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 running Apache2 2. pgsql8.2 3.JDBC driver: pg74.215.jdbc3.jar i am using jdbc client interface to pgsql database. Although i am able to connect to database server through java progm loading JDBC driver from my console(bash). BUT i am unable to run the same java progm through a html form using php....
2
1940
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 external program too?
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.