aspose file tools*
The moose likes Beginning Java and the fly likes executing cleartool from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "executing cleartool from java" Watch "executing cleartool from java" New topic
Author

executing cleartool from java

Miguel Antonioli
Greenhorn

Joined: Apr 09, 2005
Posts: 12
Howdy all,

I need some helps in running cleartool commands from inside a Java class. Cleartool is an internal command of IBM's Rational ClearCase repository software. The constraint that these commands have is that they should be executed under the mounted drive of ClearCase (in my case, it is under my M: drive). For example, to be able to run the "lshistory" command against foo.java, I should type "cleartool lshistory foo.java" under M: prompt.

I know that I should use the Runtime's exec() method. I've tried the following, but I still don't get what I want.



Theoritically, "inline" should contain the result of lshistory. But, in this instance, inline has a null.

Any helps will be greatly appreciated.

Regards,
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I'm using the ClearCase plugin for Eclipse. Perhaps taking a look at the source code available on SourceForge will help you find out how to do what you want to do.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Miguel Antonioli
Greenhorn

Joined: Apr 09, 2005
Posts: 12
Thanks Barry,
I'll look into that later.

Let's put my problem in a very generic form. Say that I have a class called command.java in which lies a method that will list the contents of a directory (by executing the dos command "dir"). I put this command.java in C: drive. What I'd like this program to do is to list the contents of another drive letter, say D: (D: will always exist). My code below will not let me do it.


Any suggestions? Thanks in advance.

[ November 11, 2005: Message edited by: Miguel Antonioli ]
[ November 11, 2005: Message edited by: Miguel Antonioli ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Using the following works for me:


It lists the files on my E: drive. Notice the File object setting the working directory to E:\
[ November 11, 2005: Message edited by: Barry Gaunt ]
Miguel Antonioli
Greenhorn

Joined: Apr 09, 2005
Posts: 12
Barry, thanks a lot. I should have checked the API before I asked
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
In Java5 look at ProcessBuilder. That makes setting up current directory, paths and environment variables for executed commands much clearer.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
 
subject: executing cleartool from java