• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing Unix Commands/Shell Scripts from Windows

 
Vinod Pushpangathan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am a new-bie to Java.
So please excuse me for my mistakes.

I have a requirement wherein I need to execute Unix commands/shell scripts
)eg: copying directories, making tar files, executing shell scripts on Unix)
from windows application as the application is developed and running on Windows platform.(Oracle Forms)

Please let me know how do I go about doing it. (Guess I need to use Java here). Appreciate your help.

Thanks
Vinod
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Have a look at class java.lang.Runtime. It contains exec(...) methods which you can use to run other programs from your Java application. Here's an article with examples. There are some potential pitfalls that can happen when you use that, however. See: this JavaWorld article.

You can also use class ProcessBuilder. See this article.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Out of the box, even Java can't execute unix shell scripts on windows.

Take a look at cygwin: http://www.cygwin.com/
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vinod,

It sounds like you want to execute Unix commands on Windows as opposed to using Windows to remotely execute commands on a Unix server?.?.

For the former, there are public domain Unix command line utilities that have been ported to DOS/Command Prompt. For the latter I would recommend doing some google'ing for rsh (remote shell) for Windows.

Hope this helps...
Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
Vinod Pushpangathan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the replies.

I still couldn't figure out how using exec I would be able to invoke unix shell scripts residing on unix box from windows. How am I supposed to pass the unix userid and password to initially connect to the unix box using exec.

I guess, if I am not wrong, servlets should be the answer as I need to have something residing on the unix box, which I can call from windows, which would do the trick for me.

Appreciate if someone can throw light on this.
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vinod,
Originally posted by Vinod Pushpangathan:
Thanks a lot for the replies.

I still couldn't figure out how using exec I would be able to invoke unix shell scripts residing on unix box from windows. How am I supposed to pass the unix userid and password to initially connect to the unix box using exec.

I guess, if I am not wrong, servlets should be the answer as I need to have something residing on the unix box, which I can call from windows, which would do the trick for me.

Appreciate if someone can throw light on this.


Now that that's clarified,
I would recommend doing some google'ing for rsh (remote shell) for Windows.


That's probably the easiest way if you're not in a secure environment. You can use exec to call the remote shell executable on Windows, which will forward the shell script command to the Unix server.

Hope this helps...
Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic