Wednesday, 15 August 2012

java - IOexception while runing bash commands through ProcessBuilder -


  

I am getting IOException when using a CAD command through a processbilder Trying:

  Error: java.io.IOException: The program can not be run "sed -i '/ hello world // g' / home / user / test": Error = 2, such a file or directory is not   

command is sed -i 's / hello world // g' / home / user / test but problem There is no command, I can run the command through the terminal only this string "Hello World" will remove

  throws a public zero extracted string (string string, string file) IOException {String command = "sed -i \ 's /" + str + "// g \" "+ File; println (command); processbiller pb = new process builder (process); process p = pb.start ();}   

what is the process of being unable to find the file?

process builder In the constructor try to run it like this: / P>

  Rosesbilder PB = new Prosesbilder ( "sed", "-i", "s / hello world // g", "/ home / user / test");   

(You can pass list & lt; string & gt; if you wish)

To prevent this security vulnerabilities Works like this for. / P>

No comments:

Post a Comment