• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Combining Unix with JAVA...

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic