jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes How I connect to remote Unix Box from standalone java application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How I connect to remote Unix Box from standalone java application?" Watch "How I connect to remote Unix Box from standalone java application?" New topic
Author

How I connect to remote Unix Box from standalone java application?

Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Hi All,
Can anybody help me regarding the Unix box connection:
I am going to write a standalone java swing application, here I planned to provide all the unix box details like-IP address/host name, user id and password. I need to read some files from the remote unix server and want to write it to the local machine. All this things I need in Windows platform.

Can anybody give me any idea, how I will connect to unix box from java?

I am waiting for the reply.


Regards, Rudra Narayan
www.garnaik.com
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

The server must provide some service (FTP, HTTP, custom server, network share) that your application can connect to. Once you determine what is available on the server, you know what you need on the client side to connect.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Access is given to me and I able to access that unix box, but how I connect to it from my java application? I need some sample java codes which will connect to my remote server(Unix box).

Please can anybody will help on this....
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

How do you access it? SSH? Telnet?
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
I am accessing my unix box through telnet.

I want to connect to it by giving the userid, password and host ip altogether.
Just look into the below command line:

telnet ://userid assword@host-ip

I am calling this line from java program.
But I unable to connect, it is giving the error:

Connecting To ://uid ass@hostip...Could not open connection to the host, on port 23: Connect failed.

Can anybody suggest me on this?

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

Originally posted by Rudra Narayan Garnaik:
I am accessing my unix box through telnet.


Great. Unfortunately, telnet doesn't have a file transfer capability, whereas SSH does. How about contacting your Unix admin, telling them what you have in mind and seeing what file transfer protocols they support?


I am calling this line from java program.
But I unable to connect, it is giving the error:


Again, you need to Tell The Details. There are many ways to "connect" to a remote server, each with it's own pitfalls. Without knowing the details of what you are doing, we can't help.
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Guys finally I got the solution for this issue:
Ist download the plink.exe from google search.
set the classpath for that.
The details are written as below:
------------------------------------------------
set CLASSPATH=%CLASSPATH%;lib\plink.exe;
plink -ssh -l userid -pw password -P 22 hostname
------------------------------------------------

If you unable to get the plink.exe then write to me so that i will help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How I connect to remote Unix Box from standalone java application?
 
Similar Threads
Standalone Java Client for WebSphere default Messaging.
Using MQ Client
If I wanted to connect and read files from remote unix box using java application
Connecting to Unix via Windows
Java Swing Application that connects to UNIX box and execute some UNIX commands