Problem running Linux bash commands in JAVA using Runtime
As mentioned what i want to do is to get bash command working in JAVA.....i tried using the following
Process p=Runtime.getRuntime().exec("sh a.sh>c.txt");
I want to redirect the output of the .sh file into another text file.
Now the problem here is that the bash is treating this the things after the space after sh as an address......that is where the problem lies...
so i put the redirection operator in the sh file itself but it still dosent work....so after revision the command comes out to be
Process p=Runtime.getRuntime().exec("sh a.sh");
It still dosent work...is there any other thing that i need to do?
Im working on Fedora 7 (moonshine).
Also where would the files to be created by sh be created?
I am not an expert in JAVA but I have some question which may lead to a solution.
1. Does your script start at all?
2. In which directory does JAVA expect the script to be?
3. What is the current directory for JAVA?
If you answer no to 1 is
Aaah...actually the code wasn't working on that particular machine....i tried,the second command,the one without the redirection operator ,out on another one n it works out just fine....and the files created are indeed created in the current working directory!
|All times are GMT -5. The time now is 11:04 PM.|