• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Executing Unix Commands/Shell Scripts from Windows

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Always look on the bright side of life. At least this ad is really tiny:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic