Start a sh file from plugin

Discussion in 'Plugin Development' started by Jalau, Dec 27, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Jalau

    So i want to start a sh file from my plugin... I'm shutting the server down and after that i want the system to run a sh file and that sh file will update the plugins , world etc from a main directory and start the server again (already did this)! But how can i run a sh file through my plugin?
     
  2. Offline

    Seadragon91

  3. Offline

    Jalau

    So how would i start an sh with this?
     
  4. Offline

    RawCode

  5. Offline

    Jalau


    It's a private plugin for my mmo server ;) So but if the server is down, the plugin can't run the code? I mean if i start the copy code when the server is going down, the code will stop when the plugin is unloaded?
     
  6. Offline

    RawCode

    if server is down no code can be run.
    you must execute shell code from separate application or at moment when server still running
     
  7. Offline

    Jalau

    Yeah so how would i manage this to work? How can i start a external sh file? Linux commandline is "./patch.sh"!

    Runtime.getRuntime().exec("patch"); <--- Found this would that run the patch.sh in the main directory of the server?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  8. Offline

    RawCode

    test it yourself, it works like CMD on windows and shell on unix.
     
  9. Offline

    Jalau

    Having a problem:

    Code:java
    1. Bukkit.shutdown();
    2.  
    3. try {
    4.  
    5. String path = serverName.toUpperCase();
    6.  
    7. Process proc = Runtime.getRuntime().exec("path"/patch.sh"); //Whatever you want to execute
    8.  
    9. BufferedReader read = new BufferedReader(new InputStreamReader(
    10.  
    11. proc.getInputStream()));
    12.  
    13. } catch (IOException e) {
    14.  
    15. System.out.println(e.getMessage());
    16.  
    17. }

    When i shutdown the server after this the script starts but seem to stop? So does the Java Process need to be still open? Can you help?
     
Thread Status:
Not open for further replies.

Share This Page