Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 19-01-2006 04:45PM
    #1
    Registered Users, Registered Users 2 Posts: 4,228 ✭✭✭


    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, Registered Users 2 Posts: 4,228 ✭✭✭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, Registered Users 2 Posts: 27,517 ✭✭✭✭GreeBo


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


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


    Why not use java.io?


Advertisement