aspose file tools*
The moose likes Java in General and the fly likes how can we connect to unix server using java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how can we connect to unix server using java program" Watch "how can we connect to unix server using java program" New topic
Author

how can we connect to unix server using java program

suresh varthi
Greenhorn

Joined: Jun 03, 2008
Posts: 1
Hi ,

I have an application in which i have to connect to unix server from a java program by providing the details ip and ID/password with in the java program(i:e the java program should ask for user id and password again) and the i need to do fallowing activities

1) run a script.
2) move to some other location.
3) removing files......etc

is it possible to do so from a java program...

Please respond for this....

thanks in advance.\

Regards.
Suresh
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Connect how? Are you talking about telnet or SSH?

If so, Apache Commons Net has a telnet client, or you can find several libraries using Google, like JSch.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
runtime = Runtime.getRuntime() // to get runtime

Then use runtime.exec("command here");

You may use System.getProperty() to identify OS.
[ June 12, 2008: Message edited by: jiju ka ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by jiju ka:
runtime = Runtime.getRuntime() // to get runtime


This would help you run something on the server if your code is running on the server, which I don't think is the case here. The solution about telnet or ssh libraries is more appropriate. Although technically, you could potentially use Runtime.exec() to execute a local ssh process which connects to the remove machine and executes a command. The solution using an ssh library would be far more portable and more efficient.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can we connect to unix server using java program