• 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

Using Java to run shell script on Unix server installed on remote macine

 
Ranch Hand
Posts: 55
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want to Use Java to run shell script on Unix server installed on remote macine.

Can you please suggest me the ways to achieve this?

Any ideas/suggestions would be higly appreciated
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a Java SSH library like JSch to connect to the remote server. If for some reason you're stuck using Telnet, check out the Apache Commons Net library for a Telnet client. You should NOT use Telnet over a public network, though.
 
Nipun Bahr
Ranch Hand
Posts: 55
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for your response.

JSch download is restricted at my place.

Can we do the same using Process Builder?

I need to run a unix script on remote machine by supplying two arguments, please suggest.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nipun Bahr wrote:
Can we do the same using Process Builder?



Since ProcessBuilder, like Runtime.exec, can only execute processes locally, that will only work if you have a process such as ssh that you can invoke, so you can invoke that process and tell it to run the remote command. For instance, you might be able to to something like


I leave the research on the details of how to make that work up to you, but one caveat I'll give you is that I don't think ssh likes taking passwords from anything other than a terminal. One way around that is to add your public key to the authorized_keys file on the remote host. You can also research those details yourself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic