• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can we connect to unix server using java program

 
suresh varthi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20613
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic