This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


JavaRanch » Java Forums » Java » Java in General
Reply locked 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: 9138
    
    9

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.


[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: 9138
    
    9

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: 9138
    
    9

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.
Koushik Paul
Greenhorn

Joined: Nov 25, 2010
Posts: 3
Joe Ess wrote: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.


I have the same requirement, I am using ftp,

I am able to fecth a file, but I need to fire some simple commands before fetching the file.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11858
    
  18

what do you mean by "simple commands"? FTP doesn't let you do much - by design. you can cd to different directories (assuming you have permission), you can get directory listings, you can delete files on the remote host (again, assuming you have permission). As far as I know, that's about it.

What EXACTLY are you trying to do?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

Fred, Paul has posted this question in a better form at http://www.coderanch.com/t/652439/java-io/java/connect-remote-Unix-Box-standalone.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
Have you checked out Aspose?
 
subject: How I connect to remote Unix Box from standalone java application?
 
It's not a secret anymore!