Results 1 to 9 of 9
  1. #1
    balakrishna is offline Member
    Join Date
    Dec 2008
    Posts
    6
    Rep Power
    0

    Exclamation How to generate auto shell script using java..

    Hi,

    I want to write a Java engine to generate shell scripts automatically by taking few inputs.

    Is there any way to do this using Java?

    Please help me..

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default hhhhmmmm...

    That's a pretty vague question.... hhhmmm... I guess so. Probably get a more definite answer if you give some more information:
    • What kind of shell scripts and how complex?
    • One kind/type of shell script or different/many types?

    I would say yes. It just depends on how complex the scripts are is the amount/level of logic that will be needed to make the code.

    Luck,
    CJSL

    PS: I'm not a "script" person... I'm just assuming the above based on my expirience with DOS .bat files
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    balakrishna is offline Member
    Join Date
    Dec 2008
    Posts
    6
    Rep Power
    0

    Unhappy Thanks anyway..

    I want to generate simple shell/DOS scripts. They may not have complexe code.

    I need something like, invoking the existing scripts to restart remote application server using a simple script

    eg script:

    cd tomcat/bin
    sh ./start stop.sh

    I'll just give the task saying restart remote app. server on so and so host.. thats it..
    My engine should generate script by itself.. that should be ready to execute..

    Only purpose it I dont want to store the scripts in file systems.

    Make sense?

  4. #4
    balakrishna is offline Member
    Join Date
    Dec 2008
    Posts
    6
    Rep Power
    0

    Unhappy Any Java API..

    Is there any open source java API available for the same?

    I thnk we can do it using Java with XSLT .. I guess so .. I m not sure..

    Guide me..

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Java?

    I'm still not sure if you want to create the scripts and execute them or just run scripts that already exist. But before it gets any further, I've got some questions:

    • What's your level of Java experience?
    • Are you looking for somebody to do this for you or are you going to do it?


    If you're looking for somebody to do it for you on this forum, that probably won't happen. If you're going to do it and is looking for guidence and help, then the forum is the right place to ask questions.

    Luck,
    CJSL

    PS: Happy Holidays
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  6. #6
    balakrishna is offline Member
    Join Date
    Dec 2008
    Posts
    6
    Rep Power
    0

    Unhappy haaa

    You are right, I am here just to have guidance.
    I want to create an engine that can develop small scripts, those may be be used to run existing scripts or may be for anything.

    In earlier post I just have mentioned an example.

    I am not getting any idea where to start, so please just give me guidance, so that I can start developing the same in Java.

    Thanks in advance.

  7. #7
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Create a File in a temp directory.
    Write your script into the file.
    Use Runtime.getRuntime().exec() to run your script.
    exec() returns a Process object. Wait for the script to complete.
    Delete the file.

  8. #8
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default hhhmmm...

    If I were to do this, I would probably think about the following:
    The app would have two mayor sections:
    • Run existing scripts
    • Create new scripts

    After running the script you could:
    • save the script for future use
    • delete the script

    Now, for creating the scripts, I would look for mayor tasks/commands. For example:
    cd
    mkdir
    etc...
    Then code the methods according to the commands that I needed. For example:
    Java Code:
    public chgDir (String path)
    {
      String chgDirPath = "cd " + path;
      return chgDirPath
    }
    Did this help?

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  9. #9
    balakrishna is offline Member
    Join Date
    Dec 2008
    Posts
    6
    Rep Power
    0

    Default Thanks a lot

    Hi,

    This is exactly I have started doing but using an open source java template engine. Using this I need to provide script template, so that the script template can be used in many places to generate scripts on fly...

    Thanks anyway..

    Regards,
    Balakrishna

Similar Threads

  1. Replies: 1
    Last Post: 02-26-2009, 07:46 AM
  2. Auto-complete/Auto-fix for custom statement
    By dark_cybernetics in forum Eclipse
    Replies: 0
    Last Post: 08-19-2008, 11:19 AM
  3. Generate an event to another java application
    By i_berbeu in forum Advanced Java
    Replies: 18
    Last Post: 05-12-2008, 01:57 PM
  4. Shell Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 07:44 PM
  5. How can I generate MsWord from java?
    By simon in forum Advanced Java
    Replies: 2
    Last Post: 08-01-2007, 04:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •