This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

executing cleartool from java

 
Miguel Antonioli
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Miguel Antonioli
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barry, thanks a lot. I should have checked the API before I asked
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java5 look at ProcessBuilder. That makes setting up current directory, paths and environment variables for executed commands much clearer.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic