File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Trapping of different shells like DOS,Unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Trapping of different shells like DOS,Unix" Watch "Trapping of different shells like DOS,Unix" New topic

Trapping of different shells like DOS,Unix

kulkarni gururaj

Joined: Mar 26, 2001
Posts: 4
I will be thankful to 'U' if u try to solve follwing :
1.As u can know one can run all the commands of a DOS prompt
e.g like this
Process p=Runtime.getRuntime.exec(Some dos command);
Like this how one can trap other shells like Unix.
(I want mainly for Enhydra shell)
Also i want more details of trapping DOS shell
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Runtime.exec() executes a command according to the local operating system. It is important to note, however that unless you explicitly ask it to, it does not run any sort of shell, jusr executes the command directly. On DOS/Windows, the upshot is largely as if you had typed the command at a DOS prompt, but because there is no DOS shell, some builtin commands will not work. On Unix, the same is generally true; most commands will work OK, but shell builtins require an explicit invocation of a shell (using "/bin/sh -c command", for example).
If you wish to invoke any other shell, you will need to run it and pass any interactive commands to it either on its command line or through the streams you get from Runtime.exec();

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Similarly, to run the commands which would be available from a DOS prompt, you must in many cases invoke cmd.exe first. This is the executable which interprets DOS comands. See this article for much more information and examples - in particular, see the program
[This message has been edited by Jim Yingst (edited March 26, 2001).]

"I'm not back." - Bill Harding, Twister
kulkarni gururaj

Joined: Mar 26, 2001
Posts: 4
Hi! FrancCarver,
Thanks,What u have told is correct.But the samething i want in more descripted way.Will u help me
I agree. Here's the link:
subject: Trapping of different shells like DOS,Unix
It's not a secret anymore!