Results 1 to 3 of 3
  1. #1
    tinnumaverick is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default how to execute commands in servlets

    I have an ingest command which i need to run to ingest objects into fedora repository.
    The command is

    /srv/fedora/client/bin/fedora-ingest.sh f SIUImages_bike.xml info:fedora/fedora-system:FOXML-1.1 test.lib.siu.edu:8080 fedoraAdmin fedoraAdmin http

    I want to execute this command in a servlet...

    I had tried

    try {
    Runtime rt = Runtime.getRuntime();

    Process pr = rt.exec("/srv/fedora/client/bin/fedora-ingest.sh f SIUImages_bike.xml info:fedora/fedora-system:FOXML-1.1 test.lib.siu.edu:8080 fedoraAdmin fedoraAdmin http");

    BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));

    String line=null;

    while((line=input.readLine()) != null) {
    out.println(line);

    }

    int exitVal = pr.waitFor();
    out.println("This is Exited with error code "+exitVal);

    }
    catch(Exception e) {
    out.println(e.toString());
    e.printStackTrace();
    }


    but no use...

    any suggestions :confused:

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    What does "no use" mean?
    Do you get exceptions?

  3. #3
    tinnumaverick is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default

    "no use" mean the command is not executed successfully. It just showed me a message
    "This is Exited with error code 0".

    I found that the file(SIUImages_bike.xml) which i am using in the command is located at path "/srv/fedora/tomcat/webapps/formConfirm/WEB-INF/classes/FOXML"

    Process pr = rt.exec("/srv/fedora/client/bin/fedora-ingest.sh f SIUImages_bike.xml info:fedora/fedora-system:FOXML-1.1 test.lib.siu.edu:8080 fedoraAdmin fedoraAdmin http");

    I want to use the path where my file is located but i doubt that "srv" is already there in the command!! How can i use the file path to run the command.

Similar Threads

  1. Need Help to Execute the commands from Java Program
    By Anjaneyulu in forum Advanced Java
    Replies: 7
    Last Post: 02-24-2010, 02:35 PM
  2. Execute the commands in Jsp Program
    By swetha_2008 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-17-2008, 06:04 AM
  3. Using Runtime to execute external commands
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-05-2008, 09:14 AM
  4. Replies: 2
    Last Post: 08-07-2007, 07:22 PM
  5. Replies: 1
    Last Post: 07-27-2007, 05:46 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
  •