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

Running Unix commands

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to run a java program on windows machines and in the program connect to a Unix machine and run Unix commands and capture the Output. Could someone point me in the right direction, what I need to use?
thanks,
Dean
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, my first question is why on earth would you want or need to do this? Sounds like you some sort of Telnet session to run from a JAVA App?
Could you tell us a little more about the need because for 1 I am curious as to why and for 2, it may help us better find a solution for you if we know.
Thanks.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dean,
Like Gregg I'm curious to know if you have a point to this excercize or just runnin' laps. You know that running a server like that on a Unix box is a giant security loophole. If you're just interested in connecting to a Unix box thru windows, I would suggest just installing an X Server on your windows machine and connecting that way.
You can take a look at the thread below, and it will show you some general techniques to kick back a remote shell. I wrote RSHServer for a Windows box, but all you should have to do is change "cmd.exe" to "/bin/sh" or "/bin/csh" or whatever shell you want on the Unix box. You can then connect to the Unix box with telnet and once you feel you have the server running, you can then start working on a client to run on the windows box. Anyway here's the thread:
Runtime exec...and br hanging
Michael Morris
 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I am looking at basicly running a telnet seesion and capturing the displayed data.
I am writing a tool which will be ran on a windows desktop and connect to Unix, Oracle servers and NT servers for monitoring data.
Any ideas to implement the telnet?
thanks again.
Dean
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dean,
One further question. Do you want to run a single command at a time or do you want a full interactive shell? Take a look at the thread link above. The code that I posted in that thread will kick back an interactive shell from an NT box as is. By changing the exec() parameter to "/bin/sh" that should kick back a bourne shell from a Unix box. You can then connect to either with telnet:

For a Unix box you may be able to get by with writing your own client if rshd or rlogind is configured to accept connections from your location. Anyway you want to look at it, you're going to need some kind of server to accept connections and do your bidding and in general you're better off getting your server up and running before you write any client code.
Michael Morris
 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking at kicking off one shell and capturing the output and than logging out.
Side note I would like to be able to open and download files stored on a Unix box as well.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic