Results 1 to 3 of 3
- 10-04-2010, 10:48 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
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:
- 10-05-2010, 10:08 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
What does "no use" mean?
Do you get exceptions?
- 10-06-2010, 06:53 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
"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
-
Need Help to Execute the commands from Java Program
By Anjaneyulu in forum Advanced JavaReplies: 7Last Post: 02-24-2010, 02:35 PM -
Execute the commands in Jsp Program
By swetha_2008 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-17-2008, 06:04 AM -
Using Runtime to execute external commands
By Java Tip in forum Java TipReplies: 0Last Post: 02-05-2008, 09:14 AM -
Need to write a program to execute a list of system commands
By mdthahir in forum New To JavaReplies: 2Last Post: 08-07-2007, 07:22 PM -
Need to write a program to execute a list of system commands
By mdthahir in forum NetworkingReplies: 1Last Post: 07-27-2007, 05:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks