Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

java Runtime.getRuntime().exec(cmd) question

Options
  • 19-01-2006 4:45pm
    #1
    Registered Users Posts: 4,222 ✭✭✭


    fixed it. delete thread please!


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Why? In future, please leave the question, and then post the solution, allowing other people the opportunity to learn.


  • Registered Users Posts: 4,222 ✭✭✭Scruff


    indeed. very thoughtless of me.
    Problem was I was trying to run the following command on linux through java:
    ls -f /proc/<pid>/fd
    

    the solution is to use
    exec(String cmd, String[] envp, File dir)
    which allows to specify which directory in which to run the command.
    File fd_dir = new File("/proc/" + pid + "/fd");
    Process p = Runtime.getRuntime().exec("ls -l", null, fd_dir);
    


  • Registered Users Posts: 27,034 ✭✭✭✭GreeBo


    ewww tying a platform independent language to a particular OS ::eek:


  • Registered Users Posts: 2,002 ✭✭✭bringitdown


    Why not use java.io?


Advertisement