aspose file tools *
The moose likes Java in General and the fly likes to run a unix script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "to run a unix script" Watch "to run a unix script" New topic
Author

to run a unix script

atlantis sundar
Greenhorn

Joined: Oct 16, 2008
Posts: 2
Hello,

I wanted to run a unix script in java application which is running in windows OS. Can any one tell how to do that with a sample code. And how to make the interaction between UNIX and windows. I am using HP UNIX. Please help me in this. Urgent.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61790
    
  67

"atlantis atlantis", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19092
    
  40

atlantis sundar wrote:
I wanted to run a unix script in java application which is running in windows OS. Can any one tell how to do that with a sample code. And how to make the interaction between UNIX and windows. I am using HP UNIX. Please help me in this. Urgent.


Well, it would help if you tell us what are you running. You start off by saying that you are running Java on Windows, and then later say that you are using HP Unix. Well, which is it?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I think it's both: my understanding is that there's a Java application on Windows from which the OP wants to run a script on an HP Unix box.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19092
    
  40

It can also be read as a script that works on HP, that the OP want to run on Windows... regardless, we need clarification. And more information, depending on what the clarification is.

Henry
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Indeed. The request for how to do the interaction between Windows and Unix is what put me on that path.

Seems like a lot to deal with for an "urgent" request ;)
atlantis sundar
Greenhorn

Joined: Oct 16, 2008
Posts: 2
Hi,

Yes, the java application is running on windows OS, and frm that application i want to trigger the unix script for which I am using HP-UNIX.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19799
    
  20

Then you need to use a protocol like Telnet or SSH. The HP UNIX machine must have a server running for one of these; I recommend SSH over Telnet because it is more secure.

Check out Apache Commons Net for a good Telnet client, and a library like JSch for SSH.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19092
    
  40

I would recommend doing it without Java first. Can you use telnet? Or does Window need to install something like Putty? Heck.... can you even ping the HP box from the windows box?

Once you confirm that the network connection is okay, and that that a particular protocol works, then you should look into the Java API that does that protocol.

Henry
 
wood burning stoves
 
subject: to run a unix script