File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Combining Unix with JAVA...

 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I just wanted to know that can i write a piece of code with which I login to an UNIX box, which I normally do in putty?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17614
38
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Although if the client machine is running Windows I'm not quite sure how. Another *n*x box could simply Runtime.exec("/usr/bin/ssh"). I think putty may have a command-line option as well, but I'm not sure. I know the cygwin package does - it's the same basic ssh program as Linux uses.

Doing a Runtime.exec of a shell program can be a little tricky because it's conversational. You have to capture stdin and stdout and use them as your conversation channels. It's easier when you just want to remotely execute a single non-interactive program/script via ssh, since you only have to worry about the output and not the input.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic