Results 1 to 6 of 6
- 11-22-2009, 11:56 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 5
- Rep Power
- 0
java.io.IOException: error=2, No such file or directory
hello :
I'm trying to execute command (//root//Cexe//test) from java application but get the error msg :
but i can execute the command //root//Cexe//test from command line window , it's my part of code :Java Code:java.io.IOException: Cannot run program "//root//Cexe//test": java.io.IOException: error=2, No such file or directory
Any idea why?Java Code:String filename="result"; BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); Datum datum = null; String[] cmd={"sudo //root//Cexe//test ",id1}; Process p =null; try{ ProcessBuilder pb = new ProcessBuilder(cmd); p = pb.start(); } catch (Exception e) { bw.write(e.toString()+'\n'); bw.write("startprocess----"); bw.write(cmd[0]); bw.write(cmd[1]); bw.flush(); bw.close(); }
thanks in advance,Last edited by NARs; 11-22-2009 at 11:58 AM.
- 11-22-2009, 12:40 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Why are you using double slashes? Only backslashes need to be escaped by another backslash.
kind regards,
Jos
- 11-22-2009, 12:59 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 5
- Rep Power
- 0
- 11-22-2009, 04:16 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
I can still see a double slash character there; but what if the sudo command requires a password? I don't see your code supplying one ...
kind regards,
Jos
- 11-22-2009, 04:27 PM #5
Member
- Join Date
- Oct 2009
- Posts
- 5
- Rep Power
- 0
hi Jos :
these if part of my code, i have check the cmd array have save my command (/root/progdir/test arg1)
but still can't execute the command using ProcessBuilder .Java Code:try{ String filename="result"; BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); Datum datum = null; String path ="/root/progdir/test "; String[] cmd={path,arg1}; bw.write(cmd[0]); //command bw.write(cmd[1]); try{ ProcessBuilder pb = new ProcessBuilder(cmd); p = pb.start(); bw.flush(); bw.close(); } catch (Exception e) { bw.write(e.toString()+'\n'); bw.write("startprocess----"); bw.write(cmd[0]); bw.write(cmd[1]); bw.flush(); bw.close(); }
Any idea will be appreciated!
cheers ,
- 11-22-2009, 04:48 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
IOException error
By eeraj in forum AWT / SwingReplies: 3Last Post: 08-31-2009, 04:05 AM -
IOException error
By eeraj in forum AWT / SwingReplies: 0Last Post: 08-29-2009, 09:12 AM -
IOException error
By eeraj in forum AWT / SwingReplies: 0Last Post: 08-29-2009, 09:02 AM -
Error: unreported exception java.io.IOException; ??
By jonsamwell in forum New To JavaReplies: 5Last Post: 08-24-2008, 04:11 AM -
java.io.IOException: CreateProcess: matlab error=2
By Jack in forum Advanced JavaReplies: 3Last Post: 04-10-2008, 09:01 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks